【问题标题】:Bootstrap Javascript not working on live websiteBootstrap Javascript 在实时网站上不起作用
【发布时间】:2015-03-26 18:08:24
【问题描述】:

我的网站遇到了一些问题。我的网络服务器中有很多 js 文件,但是 bootstrap.js 文件不起作用。这是资源的 link,它还阻止了 AddThis 共享工具。我不知道这是怎么回事!

这是我正在使用的主要 js:

<script src="http://arqetech.net/js/index.js"></script>
<script src="http://arqetech.net/js/bootstrap.js"></script>
<script src="http://arqetech.net/js/secondary.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>

这里是 website link

感谢您的宝贵时间!

【问题讨论】:

  • 您必须在 之前加载 jquery-latest.js。 Bootstrap 需要先加载 jquery。
  • 我已经有了:&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt;
  • 不,您是在 其他四个之后加载 jquery 2.1.3。你为什么要加载 jquery 两次呢?
  • 谢谢!你救了我!

标签: javascript jquery twitter-bootstrap


【解决方案1】:

您需要先加载 jQuery 脚本,然后是 Bootstrap js,最后是自定义脚本,如下所示:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>‌​
<script src="http://arqetech.net/js/bootstrap.js"></script>
<script src="http://arqetech.net/js/index.js"></script>
<script src="http://arqetech.net/js/secondary.js"></script>

要么使用这个:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

或者这个:

<script src="http://code.jquery.com/jquery-latest.js"></script>

但不是两者都

【讨论】:

  • 很高兴我能帮助 Arqetech :)
【解决方案2】:

你必须在 bootstrap 之前加载 jquery,因为 bootstrap 使用 jquery。如果任何自定义脚本也使用 jquery....jquery 必须在该自定义脚本之前加载。

我建议您使用所有 js 文件的缩小版本,因为它可以提高您的网站性能

https://developer.yahoo.com/blogs/ydn/high-performance-sites-rule-10-minify-javascript-7208.html

【讨论】:

    【解决方案3】:

    除了 jQuery 是 Bootstrap 的 Javascript 工作的先决条件(如前面的答案中所述)之外,还值得注意的是,从 v 3.3.6 开始,

    "Bootstrap 的 JavaScript 需要 jQuery 1.9.1 或更高版本,但是 低于版本 3"

    (以防万一你认为使用最新版本的 jQuery 会更好,就像我一样。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-03
      • 2016-12-19
      • 1970-01-01
      • 1970-01-01
      • 2014-12-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多