Auto select a drop down item using jQuery?

Posted by Sheonarayan under jQuery category on | Points: 40 | Views : 509
To auto select a drop item using jQuery, we write following code snippet.

<select name="myList" id="myList">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
var optionValueToSelect = "3";
$("#myList").val(optionValueToSelect );

This will select second item from the dropdown when the page loads.

Comments or Responses

Login to post response