繁体   English   中英

未捕获的类型错误:$(...).tooltip 不是函数错误

[英]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>

这里缺少什么?

编辑:

<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>

您收到错误是因为在执行脚本后加载了 jquery-ui。 您可以尝试将 type="text/javascript" 添加到您的脚本中,通常这必须解决问题,或者您必须等到脚本加载后才能执行您的工具提示。 所以你必须创建一个函数,在加载 jquery-ui 后执行你的脚本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM