I'm using Bootstrap multiselect and I would like to add an option to uncheck all selected options. Please provide me with a solution for the same. Thanks for any help :)
You can use .multiselect('refresh')
method as mentioned in the bootstrap-multiselect
documentation here.
So, add an HTML button / icon next to the multi-select select list and then use the below code:
$("#reset_client").click(function(){
$('option', $('#select_client')).each(function(element) {
$(this).removeAttr('selected').prop('selected', false);
});
$("#select_client").multiselect('refresh');
});
<select name="clients[]" multiple="multiple" id="select_client" style="display: none;">
<option value="multiselect-all"> Select all</option>
<option value="1">Client 1</option>
<option value="2">Client 2</option>
<option value="3">Client 3</option>
<option selected="selected" value="4">Client 4</option>
<option selected="selected" value="5">Client 5</option>
<option value="6">Client 6</option>
<option selected="selected" value="7">Client 7</option>
<option value="8">Client 8</option>
</select>
<input type="button" value="Reset" name="reset_clients" id="reset_client" class="reset_button" title="Clear Selection">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With