Search code examples
javascriptjqueryselecthtmlasmselect

How to default a select list to have no elements selected for use with jQuery bsmSelect plugin


I'm using the jQuery bsmSelect plugin to give my users a convenient way to select multiple options from a select-drop-down list. It works well, except I need it to start with nothing selected by default. Anyone know how this can be accomplished?

bsmSelect intro: http://www.ryancramer.com/journal/entries/select_multiple/


Solution

  • HTMLSelectElement.selectedIndex = -1;

    The ordinal index of the selected option, starting from 0. The value -1 is returned if no element is selected. If multiple options are selected, the index of the first selected option is returned.

    http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-94282980