Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
任何熟悉以下模式的人:
像
(function($){ if (jQuery.fn.pluginName) ...... } })(jQuery);
10 倍,BR
$.fn 命名空间填充了函数。如果插件存在,您可以使用它
if ($.fn.myPlugin instanceof Function) { // the plugin exists } else { // the plugin does not exist }
此外,如果这还不够,您还可以检查使用
if (typeof $.fn.myPlugin === 'function') { // The plugin exists } else { // The plugin does not exist }