<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(".add").on("click", function () { var v = $(this).closest("div.content").find("input[name=’rank’]").val(); alert(v); }); }); </script> </head> <body> <div class="content"> <div class="ranking"> <label>Rank:</label> <input type="text" name="rank" value="1"/> </div> <div class="buttons"> <a href="#" class="add">Click</a> </div> </div> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more