JQuery не определен twitter bootstrap
Я получаю эту ошибку, которая говорит, что jQuery не определен. Я хочу использовать twitter bootstrap и jQuery-UI. В моем <head>
я добавил CSS и JS. Я заметил, что на странице jQuery-UI используется 1.9.1 jQuery, а последняя версия - 1.10.2. Поэтому я предполагаю, что происходит какой-то конфликт. Щебетать bootstrap требует jQuery, чтобы вызвать ошибку. Или, возможно, я что-то делаю неправильно.
Руководитель:
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="#" onclick="location.href='http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css'; return false;" />
<link rel="stylesheet" href="#" onclick="location.href='http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css'; return false;" />
<link rel="stylesheet" href="#" onclick="location.href='http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css'; return false;" />
<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>
Ошибка:
Uncaught ReferenceError: jQuery is not defined bootstrap.min.js:6
(anonymous function) bootstrap.min.js:6
![enter image description here]()
Ответы
Ответ 1
Загрузите 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>
Ответ 2
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
добавить файл jquery js над загрузкой
Ответ 3
Я тестировал это, и этот порядок работает наилучшим образом.
- Загрузить CSS
- Загрузка jQuery
- Загрузка Bootstrap
- Загрузка jQuery UI
Ответ 4
Это, скорее всего, по двум причинам:
- Вы загружаете jQuery дважды; удалите один из них (предпочтительно более старую версию).
- Загрузите bootstrap.min.js перед загрузкой jQuery (прочтите документацию здесь).
Что вам нужно сделать:
<link rel="stylesheet" href="#" onclick="location.href='http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css'; return false;" />
<link rel="stylesheet" href="#" onclick="location.href='http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css'; return false;" />
<link rel="stylesheet" href="#" onclick="location.href='http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css'; return false;" />
<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" />