tags:

views:

58

answers:

4

Is it possible using jQuery to verify if the following HTML select list contains any items?

HTML Select List of Countries which will initially be empty and may remain so unless populated.

<select size="5" name="Country" multiple="multiple" id="Country"> 
</select>
+2  A: 

This will return true when there are items in the select.

alert($("#Country").children().length > 0);
Joel Potter
+1  A: 
if($('#Country').children().length > 0) {
    ...
}
Josh Pearce
A: 
if (0 == $('#Country option').length) {
    // no options
} else {
    // options!
}
Jordan Ryan Moore
A: 
$("#Country option").length > 0
Mark