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

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

To get the value
$("#txtName").val(),


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');


Thanks

Comments or Responses

Login to post response