DEV Community

Cover image for jQuery and Bootstrap
Ștefan Vîlce
Ștefan Vîlce

Posted on

jQuery and Bootstrap

Last weeks I commenced one new project. Actually, not new but to remake an old website. And I wanted to keep some of the functionalities from the old project. They have been simple AJAX functions build on jQuery.

And in the poject I kept the old jquery.js file.
<script src="/js/jquery.js"></script>
And then the fail appeared.

The error

Some of the features I needed from Bootstrap started to throw out some errors and didn't work properly:

alt text

The attempts

Then I started searching on internet. Of course, Stackoverflow was the first source. :)
https://stackoverflow.com/questions/28795036/jquery-javascript-not-working-in-bootstrap
Some of the answers were like this:
alt text
or like this:

use the .text() function instead of the .html()

Other answers here: https://stackoverflow.com/questions/51128079/jquery-doesnt-work-with-bootstrap/51129632

The idea is that some of these answers could fix some problems. But not mine.

The solution

First of all, it was a mistake keeping this jQuery.js file on my server. This version of jQuery was too old, I think. Actually, I'm sure about that. The second, this solution of keeping the jQuery file on my server it is not one of the best practices.
I just wanted to update my version of jQuery first and to see what to do next. So instead of
<script src="/js/jquery.js"></script>
I put
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
And when I checked the all bootstrap functionalities I needed worked.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs