disable select with only 1 option

by makloon

HTML

<select class="dropdown" id="pa_genre" name="attribute_pa_genre">
    <optgroup label="Choose an option:"></optgroup>
    <option value="sport" selected="selected">Sport</option>
</select>
<select class="dropdown" name="attribute_pa_genre">
    <optgroup label="Choose an option:"></optgroup>
    <option value="sport" selected="selected">Sport</option>
    <option value="2">something else</option>
</select>

JavaScript

$(function() {
    $("select.dropdown").each(function() {
        if ( $('option', this).length < 2 ) this.disabled = true;
    });
});