How to get/set value to HTML form element in jQuery?

Posted by Poster under jQuery category on | Views : 5541
Lets say we have a html form textbox with id as "txtName".

To get the value

To set the value
$("#txtEditName").val("My Value");

We can use the above code for dropdownlist or listbox as well.

To pre-select a DropDownList/ListBox value use
$("#drop1 option:contains("myvalue")").attr('selected', 'selected');


Comments or Responses

Login to post response