How can I select an element by name with jQuery?
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Script var name = jQuery("#form1 input[name=name]").val(); //Returns TEST1 var fathername = jQuery("#form1 input[name=fathername]").val(); //Returns TEST2 console.log(name); console.log(fathername);. HTML:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form name="form1" id="form1"> <input type="text" name="name" value="TEST1"/> <input type="text" name="<code>fathername"
value="TEST2"/> </form>You can see best example from jsfiddle
https://jsfiddle.net/alex_arriaga/vSFqW/