Answers for "select all option in select2"

0

select2 add option

// Set the value, creating a new option if necessary
if ($('#mySelect2').find("option[value='" + data.id + "']").length) {
    $('#mySelect2').val(data.id).trigger('change');
} else { 
    // Create a DOM Option and pre-select by default
    var newOption = new Option(data.text, data.id, true, true);
    // Append it to the select
    $('#mySelect2').append(newOption).trigger('change');
}
Posted by: Guest on November-06-2020
1

select2 find option by value

$('#Select2ID option[value="actualVal"]).text()
Posted by: Guest on September-17-2021
0

select2

$(".js-example-basic-multiple-limit").select2({
  maximumSelectionLength: 3
});
Posted by: Guest on February-03-2021

Code answers related to "select all option in select2"

Code answers related to "Javascript"

Browse Popular Code Answers by Language