1

How do I get an inputs content in jQuery. Like this option in JavaScript:

document.forms["Register"]["userName].value

Thanks

2
  • don't you have any id on your inputs? id selectors are better choice. Commented Nov 5, 2015 at 11:23
  • @Jai I use name attribute, not ID Commented Nov 5, 2015 at 11:24

2 Answers 2

1

Use like :

$('form[name="form1"] [name="name"]').val();

See example :

http://jsfiddle.net/maddyjolly2112/gfn46ckx/

Sign up to request clarification or add additional context in comments.

Comments

1

You can use this:

$('form[name="Register"] [name="userName"]').val();

using .filter():

$('form[name="Register"] input').filter(function(){
    return $(this).attr('name') === 'userName'
}).val();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.