【发布时间】:2016-03-21 08:08:48
【问题描述】:
我正在尝试将此代码与这些工具提示一起使用。在此链接中:Code with tooltip。事实上,我只是复制了整个代码,但它现在可以工作了。
我收到一条错误消息,上面写着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>
这里缺少什么?
编辑:
<script>
jQuery( document ).ready(function( $ ) {
$('.hasTooltip').tooltip();
});
</script>
这样使用,解决了我的问题!
【问题讨论】:
-
jsbin.com/kuteqafele/1/edit?html,output — 我无法重现该问题。
-
为什么要加载 jQuery ui 两次?
-
@JuanMendes 你的意思是?
-
@JuanMendes,一个是css,一个是js
-
@Sanchit — 在编辑问题之前加载了两个版本的 jQuery UI。
标签: javascript jquery css jquery-ui