Answers for "select2 remove all options"

4

select2 clear options

Remove the selected options : 
-----------------------------
$('#mySelect2').val(null).trigger('change');

============================================

Completly remove the select2 initialization :
--------------------------------------------
$('#payment_method').html('').select2({data: [{id: '', text: ''}]});
Posted by: Guest on July-30-2020
0

select2 clear options

$("#mySelect2").select2({
    placeholder: "Select a State",
    allowClear: true
});
Posted by: Guest on November-05-2021

Browse Popular Code Answers by Language