Selecting 2nd item from the dropdown using jQuery

Posted by Sheonarayan under jQuery category on | Points: 40 | Views : 354
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.


Comments or Responses

Login to post response