Is it possible, via jQuery, to select a multiselect to a select, differently?
The issue I’m having is that I have a general js called that does something to an id. However on some pages it has a different purpose.
Therefore I would like about to recognize the difference.
$("select#categories[multiselect]").doOneThing; //multiselect
$("select#categories").doAnotherThing; //normal single select
Possible?
The correct attribute name for a
<select>element with multiple selectable options is multiple. You can use the “has attribute” selector to select elements with the multiple attribute, and combine it with :not() to select elements that only allow a single selection.Therefore, your jQuery selector should be:
http://www.w3.org/TR/html401/interact/forms.html#edef-OPTION