错误:Bootstrap 的 JavaScript 需要 jQuery

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32166065/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 07:42:34  来源:igfitidea点击:

Error: Bootstrap's JavaScript requires jQuery

javascriptjqueryhtmlajaxtwitter-bootstrap

提问by moin khan

When i run my site on mozilla i got this error above.Here some code snippet which might be helpful

当我在 mozilla 上运行我的网站时,我在上面遇到了这个错误。这里有一些可能有用的代码片段

<script src="http://www.iclubz.com/js/jquery.js"></script>

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

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

<script src="http://www.iclubz.com/js/readmore.min.js"></script>

<script src="http://www.iclubz.com/js/chosen.jquery.js"></script>

<script src="http://www.iclubz.com/js/jquery.validate.min.js"></script>

<script src="http://www.iclubz.com/js/fileinput.min.js"></script>

But it's work fine on chrome.I don't know why this problem are showing.I'll helpful if anyone tell me the reason

但它在 chrome 上工作正常。我不知道为什么会出现这个问题。如果有人告诉我原因,我会有所帮助

Thanks in advance

提前致谢

Edited: i forgot to mention that all my javascript are called in the bollom of the page

编辑:我忘了提到我所有的 javascript 都是在页面的 bollom 中调用的

回答by nikistag

Make sure to load jquery.js file before loading bootstrap. This solved my problem.

确保在加载引导程序之前加载 jquery.js 文件。这解决了我的问题。

回答by Hristo Georgiev

That error can only be caused by one of three things:

该错误只能由以下三种情况之一引起:

  • Your JavaScript file is not being properly loaded into your page

  • You have a botched version of jQuery. This could happen because someone edited the core file, or a plugin may have overwritten the $ variable.

  • You have JavaScript running before the page is fully loaded, and as such, before jQuery is fully loaded. You should check the Firebug net panel to see if the file is actually being loaded properly.

    If not, it will be highlighted red and will say "404" beside it. If the file is loading properly, that means that the issue is number 2.

  • 您的 JavaScript 文件未正确加载到您的页面中

  • 你有一个拙劣的 jQuery 版本。这可能是因为有人编辑了核心文件,或者插件可能覆盖了 $ 变量。

  • 您在页面完全加载之前运行 JavaScript,因此,在 jQuery 完全加载之前。您应该检查 Firebug 网络面板以查看文件是否真正正确加载。

    如果没有,它将突出显示为红色,并在旁边显示“404”。如果文件加载正确,则意味着问题是第 2 个问题。

Make sure all javascript code is being run inside a code block such as:

确保所有 javascript 代码都在代码块中运行,例如:

$(document).ready(function () {
  //your code here
});

回答by tayfun K?l??

Your first load jquery.js(min) then boostrap load

你首先加载 jquery.js(min) 然后 boostrap 加载

<script src="/node_modules/bootstrap/dist/js/bootstrap.js"></script>