select2 selected option code example
Example 1: select2
$('.js-example-basic-single').select2({
placeholder: 'Select an option'
});
Example 2: select2
$(".js-example-basic-multiple-limit").select2({
maximumSelectionLength: 3
});
Example 3: select2 .select2-results .select2-highlighted
#menuOption1-container .select2-results__option--highlighted {
background-color: #50831F !important;
}
#menuOption2-container .select2-results__option--highlighted {
background-color: #28915F !important;
}
Example 4: select2 .select2-results .select2-highlighted
$(document).ready(function() {
$("#menuOption1").select2({dropdownParent: "#menuOption1-container"});
$("#menuOption2").select2({dropdownParent: "#menuOption2-container"});
});