Put JS in only one div

0

My question is as follows, I have a div that I need to have a less updated version of js .

My page has Bootstrap 4.1 and I need to run jquery 2.2.3 in the div where the most up-to-date (3.2.1) causes the content to blink and does not display correctly.

    
asked by anonymous 17.09.2018 / 17:04

1 answer

5

Yes you can use multiple versions on the same page. jquery allows this using a function called noConflict . In your case it would look like this to load the scripts on the page:

 <script src="jquery/3.2.1/jquery.js" type="text/javascript"></script>
 <script src="jquery/2.2.3/jquery.js" type="text/javascript"></script>
 <script>var $j = jQuery.noConflict(true);</script>

When using $() you will be using version 3.2.1, when using $j() you will be using version 2.2.3.

So, whatever that particular div is referenced, use $j , which can be renamed to something else you like, such as $j223 , and correctly put the names of the files in the script tag.

Here's the documentation: jquery.noconflict

    
17.09.2018 / 17:12