简体   繁体   中英

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. But when i am loading my page the browser console throw an error says : Uncaught Error: Bootstrap's JavaScript requires 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. Use relative path instead.

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. And don't forget to wrap your code inside a document ready jquery function

To begin, you must change the location of the tag 'script' into the tag 'head'. after this, you must change the location of your javascript scripts to your project directory. Finally, you change the value of the 'src' attribute to: Ex:

  • src="../js/jquery.js"
  • src="../js/bootstrap.min.js"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM