Getting a form value with jQuery
jQuery uses val() function to get a form values. Below is the example form with id city.
Now we will get the value from id “city” and display an alert:
If you’re using the name only and not specifying an id, the jQuery to get the form values would be this:
Setting a form value with jQuery
You can easilly set the form values with jQuery using the same val() function but passing it a new value. Using the same example forms above, you can do this for the text input.