Quick way to clear all selections on a multiselect enabled <select> with jQuery? Quick way to clear all selections on a multiselect enabled <select> with jQuery? jquery jquery

Quick way to clear all selections on a multiselect enabled <select> with jQuery?


Simply find all the selected <option> tags within your <select> and remove the selected attribute:

$("#my_select option:selected").removeAttr("selected");

As of jQuery 1.6, you should use .prop instead of removing the attribute:

$("#my_select option:selected").prop("selected", false);


In order to clear all selection, I am using like this and its working fine for me.here is the script:

 $("#ddlMultiselect").multiselect("clearSelection"); $("#ddlMultiselect").multiselect( 'refresh' );


Shortest and quickest way to remove all the selection, is by passing empty string in jQuery .val() function :

$("#my_select").val('')