Skip to main content | Turn off styling Default page style

Question & Answer index

Using jQuery,how do you get the value of a form input?

How do you get the value depends on what type of input it is.

See related:

Select Box

Sample select box/drop-down
Show value
show text

Here is the HTML for the select box and the "show selection" link:

For a select box, you can use this to get the value:
and you can use this to get the text:
$('#SelectBoxID option:selected').text();

In this example, I pass the name of the id of the select box into the function and "alert" the result. You could easily change this to "return" the value or assign the value to a variable.