I am think this should be fairly easy, but struggling a bit ... I have a SELECT input element that allows the user to select multiple items. I would like to provide a mechanism for them to clear all selected items, probably will just be a SPAN tag or something similar.
Anyway ... using jQuery, how I would I clear the selection on the SELECT input element so no items are selected.
This worked to clear all selected options for me..
$("#selectListName").prop('selectedIndex', -1)
The select list looked like
<select multiple='multiple' id='selectListName'>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
Try: // Just put # before select to fix this. Works perfect. $("#select option:selected").each(function () { $(this).remove(); //or whatever else });