How can I get the value of an input element in jQuery?
-
8Felix: "google it" is not an acceptable answer.user113292– user1132922010-09-09 05:25:26 +00:00Commented Sep 9, 2010 at 5:25
-
1Mark i think Felix is not giving an answer just extending help to find solution by himselfsushil bharwani– sushil bharwani2010-09-09 05:28:38 +00:00Commented Sep 9, 2010 at 5:28
-
on the other hand - good to have an answer to everything on SO :)Bozho– Bozho2010-09-09 05:31:19 +00:00Commented Sep 9, 2010 at 5:31
Add a comment
|
5 Answers
If this is your textbox:
<input type="text" id="mytextBox" value="" />
You will be getting it's value using the textbox's ID=mytextBox...
var value = $("#mytextBox").val()
References
Comments
The best way is to use the val() function, as in:
$('#someInput').val();
You can also use the attr function to find the value for some fields
$('#someInput').attr('value');
1 Comment
sarfarazsajjad
how to set the attribute ?