Jquery Setting Value of Input Field

The val() method returns or sets the value attribute of the selected elements.

To get a form value with jQuery use the val() function. Let’s say we have a form like this, using an id for each form element.


<input id="userName" name="userName" type="text" value=""/>

jQuery Code


Empty Value


Leave a Reply

Your email address will not be published. Required fields are marked *