[英]Uncaught: Bootstrap's JavaScript requires jQuery
I have included jquery and bootstrap.min.js file in my footer section or it means i have my all script tag at the bottom of the code. 我在页脚部分包含了jquery和bootstrap.min.js文件,或者这意味着我的所有脚本标签都位于代码底部。 But when i am loading my page the browser console throw an error says : Uncaught Error: Bootstrap's JavaScript requires jQuery.
但是,当我加载页面时,浏览器控制台会抛出一个错误消息: 未捕获的错误:Bootstrap的JavaScript需要jQuery。 I am including these files locally like below:-
我在本地包含这些文件,如下所示:-
</footer>
<script src="http://127.0.0.1/ems_ci/assets/js/jquery.js" type="text/javascript"></script>
<script src="http://127.0.0.1/ems_ci/assets/js/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
It's uncommon to use localhost
or 127.0.0.1
for a file path. 使用
localhost
或127.0.0.1
作为文件路径并不常见。 Use relative path
instead. 请改用
relative path
。
Regarding script position: you can leave them in the footer, that will speed up page loading, but make sure any JavaScript code you execute is AFTER jquery/bootstrap in the dom. 关于脚本位置:您可以将它们放在页脚中,这将加快页面加载速度,但请确保您执行的任何JavaScript代码在dom之后是jquery / bootstrap。 And don't forget to wrap your code inside a
document ready
jquery function 并且不要忘记将代码包装在
document ready
jquery函数中
To begin, you must change the location of the tag 'script' into the tag 'head'. 首先,必须将标签“ script”的位置更改为标签“ head”。 after this, you must change the location of your javascript scripts to your project directory.
之后,必须将javascript脚本的位置更改为项目目录。 Finally, you change the value of the 'src' attribute to: Ex:
最后,将“ src”属性的值更改为:例如:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.