For Example if we are using any CDN to load JQuery in our application and some times CDN may be blocked by the user or CDN Server is not reachable/down. So Its always better to check if jQury plugin is loaded or not once before using it.
To check if jQuery library is loaded?
to check if jQuery library and plugin is loaded?
to check if jQuery library and plugin is loaded?
to check if jQuery library
to check if jQuery library
if (typeof jQuery != 'undefined') {
alert("jQuery library is loaded!");
}
Or We can Check like below
if (jQuery) {
alert("jQuery library is loaded!");
}
Using Above methods we can Check If JQuery library is loaded r not. To Check If any particular jQuery plugin is loaded or not, we can use below method.
To check if jQuery Plug-in is loaded?
if(jQuery().pluginMethod) {
alert("jQuery Plugin is loaded!");
}
To check if validation plugin is loaded or not using JQuery.
if(jQuery().validate) {
alert("Validation plugin exists");
// Now I can use $('#someId').validate()
}
We can also use jQuery isFunction() to determine if a there're a jQuery UI function.for Ex:- To Check if datepicker exists/ loaded or not
jQuery(document).ready(function() {
if (jQuery.isFunction(jQuery.fn.datepicker)) {
console.log('datepicker Present')
}
});
No comments:
Post a Comment