How to clear all selected items in a SELECT input using jQuery?
Try: // Just put # before select to fix this. Works perfect. $("#select option:selected").each(function () { $(this).remove(); //or whatever else });
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>
Only this worked for me:-
$("#selectid").find('option').attr("selected",false) ;
In the case of a <select multiple>
the .val()
function takes/returns an array, so you can simply pass in an empty array to clear the selection, like this:
$("#selectID").val([]);
You can test it out here.