If I manually enter text into an input element, I can call $("#myinput").val() and get a value.
If I set it first like $("#myinput").val("foo") and then call $("#myinput").val(), it returns nothing.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
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.
Make sure you have only one input on the page with
id="myinput"Answer Based on Original Question:
$("input").val()returns the value of the first input of the pageif
#myinputis not first, it will not be shown.To get all the vals of all the inputs on the page you can do: