It's me ;-)

How to select the first option in a combo box?

Simply in jQuery (a Javascript framework – Write less, do more):

$("#div_id option:first).attr("selected","selected"); 

Example: 

$('#myCombo').load(
                              'my_combo.php?foo=bar',
                               function() {
                                     $('#myCombo option:first).attr("selected","selected");
                               }
                      );
html:

2 thoughts on “How to select the first option in a combo box?

Leave a Reply

Your email address will not be published. Required fields are marked *