javascript - Uncaught TypeError : $(. ..).tooltip is not a function 错误

标签 javascript jquery css jquery-ui

我正在尝试将此代码与这些工具提示一起使用。在这个链接中: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>

这样用,解决了我的问题!

最佳答案

您为不同版本包含了两次 jQuery UI。这可能会导致冲突。尝试删除

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

关于javascript - Uncaught TypeError : $(. ..).tooltip is not a function 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34290847/

相关文章:

javascript - 为什么 Safari 页面会破坏 iOS 渲染?

javascript - 如何获取兄弟节点并在javascript更改事件上设置值?

jQuery - 使用wrap() 来包装多个元素?

javascript - 对齐 x 按钮和关注取消关注按钮。

javascript - 当鼠标悬停在页面加载时的框上时,停止 jQuery 运行

javascript - 如何在 jquery 对话框中的固定宽度文本框中显示可变长度文本

css - 如何使用 SquishIT 对 CSS 图像的 URL 进行指纹识别

Html 正斜杠显示不正确(Chrome 和 Edge)

javascript - jQuery,将成功数据从 AJAX 传递到另一个函数?

javascript - fileReader 输入更改 JQuery