【问题标题】:Uncaught TypeError: $(...).tooltipster is not a function [duplicate]未捕获的 TypeError:$(...).tooltipster 不是函数 [重复]
【发布时间】:2017-04-24 09:29:46
【问题描述】:

我不能将 tooltipster 库与 tablesorter 一起使用,因为它会引发错误:

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

还有我的代码:

<html><head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script>
<script type="text/javascript" src="llibreries/tooltipster/dist/js/tooltipster.bundle.min.js"></script>
<link rel="stylesheet" href="css/jq.css" type="text/css" media="print, projection, screen" />
<link rel="stylesheet" href="themes/blue/style.css" type="text/css" media="print, projection, screen" />
<link rel="stylesheet" href="css/vista.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="llibreries/tooltipster/dist/css/tooltipster.bundle.min.css" />

<script type="text/javascript">
        $(document).ready(function() {
                $('.tooltip').tooltipster({
        contentCloning: false
        });
        });
</script>

<script type="text/javascript" src="llibreries/jquery-latest.js"></script> 
<script type="text/javascript" src="llibreries/jquery.tablesorter.js"></script>
<script type="text/javascript" src="js/docs.js"></script>
<script type="text/javascript" src="addons/pager/jquery.tablesorter.pager.js"></script>

    <script type="text/javascript">
        $(function() 
    {
                $("table")
                .tablesorter({widthFixed: true, widgets: ['zebra']})
                .tablesorterPager({container: $("#pager")
    });
    });
    </script></head> ....

如果我评论第二个脚本 $("table").tablesorter... 工具提示脚本有效。否则,它不会。不能让它工作,我做错了什么?

【问题讨论】:

  • 不要两次包含 jQuery。这是个问题。
  • 同意。取出第二个 jquery 引用,然后重试。包含两次几乎总是会导致问题。

标签: javascript jquery tooltipster


【解决方案1】:

请检查嵌入在标题中的 CDN 的链接

请查看链接CDN for the Tooltipster

这是错误的

<script type="text/javascript" src="llibreries/tooltipster/dist/js/tooltipster.bundle.min.js"></script>
<link rel="stylesheet" type="text/css" href="llibreries/tooltipster/dist/css/tooltipster.bundle.min.css" />

试试这个

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/js/jquery.tooltipster.js"></script>

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/css/tooltipster.min.css" />

<html><head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/js/jquery.tooltipster.js"></script>
<link rel="stylesheet" href="css/jq.css" type="text/css" media="print, projection, screen" />
<link rel="stylesheet" href="themes/blue/style.css" type="text/css" media="print, projection, screen" />
<link rel="stylesheet" href="css/vista.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/css/tooltipster.min.css" />

<script type="text/javascript">
        $(document).ready(function() {
                $('.tooltip').tooltipster({
        contentCloning: false
        });
        });
</script>

<script type="text/javascript" src="llibreries/jquery-latest.js"></script> 
<script type="text/javascript" src="llibreries/jquery.tablesorter.js"></script>
<script type="text/javascript" src="js/docs.js"></script>
<script type="text/javascript" src="addons/pager/jquery.tablesorter.pager.js"></script>

    <script type="text/javascript">
        $(function() 
    {
                $("table")
                .tablesorter({widthFixed: true, widgets: ['zebra']})
                .tablesorterPager({container: $("#pager")
    });
    });
    </script></head>
    <body>
    </body>
    </html>

$(document).ready(function() {
  $('.tooltip').tooltipster({
    contentCloning: false
  });
});
<html><head>
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/js/jquery.tooltipster.js"></script>
  <link rel="stylesheet" href="css/jq.css" type="text/css" media="print, projection, screen" />
  <link rel="stylesheet" href="themes/blue/style.css" type="text/css" media="print, projection, screen" />
  <link rel="stylesheet" href="css/vista.css" type="text/css" />
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/tooltipster/3.3.0/css/tooltipster.min.css" />
  <script type="text/javascript" src="llibreries/jquery-latest.js"></script> 
  <script type="text/javascript" src="llibreries/jquery.tablesorter.js"></script>
  <script type="text/javascript" src="js/docs.js"></script>
  <script type="text/javascript" src="addons/pager/jquery.tablesorter.pager.js"></script>
</head>
    <body>
    </body>
</html>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2017-01-26
  • 1970-01-01
  • 2018-01-02
  • 1970-01-01
  • 2016-01-21
  • 2020-09-05
  • 2020-01-05
  • 1970-01-01
相关资源
最近更新 更多