Uncaught TypeError: $(…).tooltipster is not a func

2019-09-15 06:38发布

This question already has an answer here:

I can't use the tooltipster library along with tablesorter one as it throws an error:

Uncaught TypeError: $(...).tooltipster is not a function

And my code:

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

If I comment the second script $("table").tablesorter... The tooltip script works. Otherwise, it doesn't. Can't make it work, what am I doing it wrong?

1条回答
迷人小祖宗
2楼-- · 2019-09-15 07:35

Please check the links for the CDN embedded in the header

Please check the link CDN for the Tooltipster.

This is wrong

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

Try this

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

查看更多
登录 后发表回答