Wednesday, October 9, 2013

Selecting First Option of a Drop Down/Combo Box using JQuery

This one is pretty simple and straight forward. I am just placing it here for future reference and may be it will be helpful to people looking for a similar solution.

If you want to select the first option of an HTML drop down/select control/combo box, just use the following:

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

I found the solution on Stack Overflow.

Hope it helps, if it does just drop a comment, it will keep me motivated :)