Answers for "select2 unselect all options"

3

select2 preselect option

$('#mySelect2').val('1'); // Select the option with a value of '1'
$('#mySelect2').trigger('change'); // Notify any JS components that the value changed
Posted by: Guest on November-09-2020
1

select2 clear selected

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

Browse Popular Code Answers by Language