How to Check if a jQuery Function is Defined
You can use the 'typeof' operator to check if a jQuery function is defined. For example:
if (typeof jQuery.fn.myFunction === 'function') {
// myFunction is defined
} else {
// myFunction is not defined
}
In this example, 'jQuery.fn.myFunction' is the function you want to check if it is defined. The 'typeof' operator will return 'function' if the function is defined, and 'undefined' if it is not defined.
原文地址: https://www.cveoy.top/t/topic/mzZV 著作权归作者所有。请勿转载和采集!