[英]Uncaught TypeError: $(...).tooltip is not a function error
I'm trying to use this code with those tooltips.我正在尝试将此代码与这些工具提示一起使用。 In this link: Code with tooltip .
在此链接中:带有工具提示的代码。 In fact I just copied the whole code but it's now working.
事实上,我只是复制了整个代码,但它现在可以工作了。 I get an error that says
Uncaught TypeError: $(...).tooltip is not a function error
:我收到一条错误消息,指出
Uncaught TypeError: $(...).tooltip is not a function error
:
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$(document).tooltip({
position: {
my: "center bottom-20",
at: "center top",
using: function(position, feedback) {
$(this).css(position);
$("<div>")
.addClass("arrow")
.addClass(feedback.vertical)
.addClass(feedback.horizontal)
.appendTo(this);
}
}
});
});
</script>
What is missing here?这里缺少什么?
Edit:编辑:
<script>
jQuery( document ).ready(function( $ ) {
$('.hasTooltip').tooltip();
});
</script>
Using it like this, solved my problem!像这样使用它,解决了我的问题!
You are including two times the jQuery UI for different versions.您为不同版本包含了两倍的 jQuery UI。 This might be causing conflicts.
这可能会导致冲突。 Try removing
尝试删除
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
You are getting the error because jquery-ui is loaded after your script is executed.您收到错误是因为在执行脚本后加载了 jquery-ui。 you can try to add type="text/javascript" to your scripts normally this must resolve the issue or you must wait until the script is loaded to execute your tooltip.
您可以尝试将 type="text/javascript" 添加到您的脚本中,通常这必须解决问题,或者您必须等到脚本加载后才能执行您的工具提示。 so you must creat a function that will execute your script after the jquery-ui is loaded.
所以你必须创建一个函数,在加载 jquery-ui 后执行你的脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.