I have this element:
<input type="text" id="unique_id" />
and I want to get the input string whenever there is some text in the form and the user presses enter.
Is that possible? How do I do it?
Thanks!
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.
You can access the element the same way as any other, just use an
idselector:The above will log, to the JavaScript console, the current value of the
inputelement on every keypress. If you only need to know what the value is when data entry is complete, then use eitherblur(), orchange():Note: you don’t need to use both, I’m just showing them both so you can see how to use them.
References:
blur().change().keypress().