jQuery没有定义twitter bootstrap

Lio*_*cer 16 html javascript css jquery twitter-bootstrap

我收到这个错误,说jQuery没有定义.我想使用twitter bootstrap和jQuery-UI.在我,<head>我已经添加了CSS和JS必要的.我注意到jQuery-UI页面使用1.9.1 jQuery,最新版本是1.10.2.所以我假设存在某种冲突.Twitter引导需要jQuery,以便可能导致错误.或许我做错了什么.

头:

<head>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css" />
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

</head>
Run Code Online (Sandbox Code Playgroud)

错误:

Uncaught ReferenceError: jQuery is not defined          bootstrap.min.js:6
(anonymous function)                                    bootstrap.min.js:6
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

tym*_*eJV 47

在其他一切之前加载jQuery!

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
Run Code Online (Sandbox Code Playgroud)

  • 总是在JS之前加载CSS (7认同)
  • 对我不起作用.我在Bootstrap之前有jQuery并且无论如何都会得到错误! (6认同)
  • 为什么你多次打电话给jquery.你可以解释一下吗? (2认同)

小智 5

这很可能是由于两个原因:

  1. 你正在加载jQuery两次; 删除其中一个(最好是旧版本).
  2. 您在加载jQuery之前加载bootstrap.min.js(请阅读此处的文档).

你需要做的是:

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" />
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js" />
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js" />
Run Code Online (Sandbox Code Playgroud)