Reputation: 350
How do I get an inputs content in jQuery. Like this option in JavaScript:
document.forms["Register"]["userName].value
Thanks
Upvotes: 1
Views: 29
Reputation: 1287
Use like :
$('form[name="form1"] [name="name"]').val();
See example :
http://jsfiddle.net/maddyjolly2112/gfn46ckx/
Upvotes: 1
Reputation: 74738
You can use this:
$('form[name="Register"] [name="userName"]').val();
using .filter()
:
$('form[name="Register"] input').filter(function(){
return $(this).attr('name') === 'userName'
}).val();
Upvotes: 1