![[JS] Check select2 jquery plugin loaded or not [JS] Check select2 jquery plugin loaded or not](https://res.cloudinary.com/dimaslanjaka/image/fetch/https://laraget.com/images/blog/1482184906-Select2.png)
[JS] Check select2 jquery plugin loaded or not
2019-06-26 / Dimas Lanjaka Kumala Indra
Read How to async defer CSS JS perfectly
if (jQuery.fn.select2) { //jquery select2 loaded or not false or not undefined => return array
jQuery.fn.select2.defaults.set( “theme”, “bootstrap” ); //then select themes
}
Example: How to change select2 jQuery plugin using jQuery.val()
$(’#mySelect2’).val(‘US’); // Change the value or make some change to the internal state
if (jQuery.fn.select2) {
$(’#mySelect2’).trigger(‘change.select2’); // Notify only Select2 of changes
}
[JS] Check select2 jquery plugin loaded or not
PermaLink: https://www.webmanajemen.com/2019/06/check-select2-jquery-plugin-loaded-or.html
Google Rich Snippets | Schema Markup Validator | Google Pagespeed Insight