$.Zebra_Tooltips 不是构造函数
$.Zebra_Tooltips is not a constructor
我正在使用 zebra 工具提示插件 jquery 1.12.4 (Wordpress)
我收到 $.Zebra_Tooltips is not a constructor
错误。
这是我的代码:
new jQuery.Zebra_Tooltips($('.zebra_tooltips'), {
'animation_speed':50,
'animation_offset':10,
'hide_delay':0,
'show_delay':0
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zebra_tooltips@2.0.5/dist/css/default/zebra_tooltips.min.css">
<script src="https://cdn.jsdelivr.net/npm/zebra_tooltips@latest/dist/zebra_tooltips.min.js"></script>
<p>
<a href="javascript: void(0)"
class="zebra_tooltips"
title="Zebra Tooltips is a lightweight and highly configurable jQuery tooltips plugin">
Over here!</a>
</p>
我有两个解决方法,但由于我对 jQuery 了解不多,所以我不确定哪个最好,也不确定它们是否都是 'safe'。
Zebra_tooltips 不是为在 Wordpress 中使用而编写的。
在脚本中,他们将所有代码包含在:
(function($) {
})($);
但在 Wordpress 中,“$”并不意味着 'jQuery',因为 Wordpress 已将其抑制(抱歉,如果我在技术上不正确)
所以Zebra_tooltips脚本不知道最后的($)表示jQuery
解决方案 1
编辑 Zebra_tooltips 脚本,使最后一行为
})(jQuery);
而不是
})($);
这意味着您必须自己对 Zebra_tooltips 脚本进行 'minification',如果 Zebra_tooltips.[=14 有更新,您将不得不重新编辑=]
解决方案 2
添加:
var $=jQuery.noConflict();
到您自己的脚本,然后再调用 Zebra_tools
这告诉 Zebra_tools(和 Wordpress)'$' 表示 jQuery。
我在这里看到的一个问题是,如果任何其他类型的脚本(不是 jQuery)也在使用 $ 那么这可能会阻止其他脚本工作。
我正在使用 zebra 工具提示插件 jquery 1.12.4 (Wordpress)
我收到 $.Zebra_Tooltips is not a constructor
错误。
这是我的代码:
new jQuery.Zebra_Tooltips($('.zebra_tooltips'), {
'animation_speed':50,
'animation_offset':10,
'hide_delay':0,
'show_delay':0
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/zebra_tooltips@2.0.5/dist/css/default/zebra_tooltips.min.css">
<script src="https://cdn.jsdelivr.net/npm/zebra_tooltips@latest/dist/zebra_tooltips.min.js"></script>
<p>
<a href="javascript: void(0)"
class="zebra_tooltips"
title="Zebra Tooltips is a lightweight and highly configurable jQuery tooltips plugin">
Over here!</a>
</p>
我有两个解决方法,但由于我对 jQuery 了解不多,所以我不确定哪个最好,也不确定它们是否都是 'safe'。 Zebra_tooltips 不是为在 Wordpress 中使用而编写的。
在脚本中,他们将所有代码包含在:
(function($) {
})($);
但在 Wordpress 中,“$”并不意味着 'jQuery',因为 Wordpress 已将其抑制(抱歉,如果我在技术上不正确)
所以Zebra_tooltips脚本不知道最后的($)表示jQuery
解决方案 1
编辑 Zebra_tooltips 脚本,使最后一行为
})(jQuery);
而不是
})($);
这意味着您必须自己对 Zebra_tooltips 脚本进行 'minification',如果 Zebra_tooltips.[=14 有更新,您将不得不重新编辑=]
解决方案 2
添加:
var $=jQuery.noConflict();
到您自己的脚本,然后再调用 Zebra_tools
这告诉 Zebra_tools(和 Wordpress)'$' 表示 jQuery。
我在这里看到的一个问题是,如果任何其他类型的脚本(不是 jQuery)也在使用 $ 那么这可能会阻止其他脚本工作。