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
2010-03-05 23:33:02
+2
A:
Here's what you are looking for:
$('select > option')[0].selected = true;
aefxx
2010-03-05 23:38:25
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
2010-03-05 23:41:51