TypeError:$(…).tooltip不是函数 [英] TypeError: $(…).tooltip is not a function

查看:132
本文介绍了TypeError:$(…).tooltip不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到

TypeError:$(...).tooltip不是函数

TypeError: $(…).tooltip is not a function

在将lightbox2与bootstrap一起使用时,我正在初始化tooltip()函数的jquery文件中的错误.

error in the jquery file in which i am initialising tooltip() function while using lightbox2 with bootstrap.

$(function() {
  $('[data-toggle="tooltip"]').tooltip({
      html: true
  });
});

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
        <script src="bootstrap/js/bootstrap.js"></script>
        <script src="main.js"></script>
</head>
<body>
  <script src="lightbox-plus-jquery.min.js"></script>
</body>

推荐答案

当两次包含jQuery时,可能会发生这种情况.

This can happen when jQuery is included twice.

对于使用Rails的人,默认情况下已经包含jQuery(请检查app/assets/javascripts/application.js):

For people using Rails, jQuery is already included by default (check app/assets/javascripts/application.js):

//= require jquery

再次包含jQuery,例如在app/views/layouts/application.html.erb中使用<script>标记,将导致此错误.

Including jQuery again, for example with a <script> tag in app/views/layouts/application.html.erb, will result in this error.

解决方案是删除app/views/layouts/application.html.erb中的<script>标签.

The solution is to remove the <script> tag in app/views/layouts/application.html.erb.

这篇关于TypeError:$(…).tooltip不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆