Wednesday, January 18, 2012

jquery select first option from select

How to select first option element from a select.

Get the value of first option:
var val-to-select = $('#selector-id').find('option:first').val();

Select it:
$('#selector-id').val(val-to-select);

No comments: