Auto select a drop down item using jQuery?

Sheonarayan
Posted by Sheonarayan under jQuery category on | Points: 40 | Views : 3845
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>
</select>
<script>
var optionValueToSelect = "3";
$("#myList").val(optionValueToSelect );
</script>

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

Comments or Responses

Login to post response