Selecting 2nd item from the dropdown using jQuery

Sheonarayan
Posted by Sheonarayan under jQuery category on | Points: 40 | Views : 391
Sometimes, you might have got an requirement where when page loads, we need to select 2nd item from the dropdown or listbox. Here is the code snippet for that.

$("#LocationId").val($("#LocationId option:first").next().val());


To select first item from dropdown, use below

$("#LocationId").val($("#LocationId option:first").val());


Hope this helps.

Thanks

Comments or Responses

Login to post response