I have a
<input type='text' id='text' value='' />
How do I programmatically set the value attrribute using JQuery/Javascript
jQuery val() Method The val() method returns or sets the value attribute of the selected elements. When used to return value: This method returns the value of the value attribute of the FIRST matched element.
val() method is primarily used to get the values of form elements such as input , select and textarea . When called on an empty collection, it returns undefined .
The simple easy way is:
$("#text").val ("foo");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With