how can I check to see if my <select> element contains the multiple attribute

javascript, jquery

Solution

remove `:` at the beginning of :

if($("select[multiple]").length){
    alert("worked");
}

Demo : http://jsfiddle.net/D5JX5/

Problem

hi I have tried many options to check if the multiple attribute is set in my select box but none have worked. I am trying to determine if the current select box that I am getting values from is a multiple select so far this is what I have tried: ``` if($(":select[multiple]").length){ alert("worked"); } ``` also ``` if($("select").attr("multiple"){ alert("worked"); } ``` also ``` if($("select").attr("multiple") != 'undefined'{ alert("worked"); } ``` html: ``` <select multiple="multiple" style="height:50px" class="classname" name="multi_values[]"> <option value="blah">blah</option> <option value="blah">blah</option> <option value="blah">blah</option> </select> ```

Original source

Related problems