Khanh's blog

<- Quay về trang chủ

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:

Tags: jquery