tags:

views:

50

answers:

3

I have a list in a select. After selecting an option i do a check and occasionally i want to change the selected to index 0 (first option, value=""). How do i set the select to that option with jquery?

A: 

$('select > option')[0].attr('selected','selected') should work i think

ocdcoder
+2  A: 

Here's what you are looking for:

$('select > option')[0].selected = true;
aefxx
A: 

select > option = get descendant of select :eq(0) means get the first (index=0) and then set attribute

$("select > option:eq(0)").attr("selected","selected")
Anatoly G