Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple versions of JQuery on the same page [duplicate]

Tags:

jquery

Is it possible to handle conflicts between 2 versions of jQuery loaded in the same page? Assume that these lines of code:

<script type="text/javascript" src="jquery-1.1.3.js"></script>
<script type="text/javascript" src="jquery-1.4.2.js"></script>

<script type="text/javascript" src="thisFileUsesFirstJquery.js"></script>
<script type="text/javascript" src="thisFileUsesSecondJquery.js"></script> 

I don't use inline java script code. In my situation, my java script code take place on external file. My question is: How should I use noConflict() method that prevent from conflicting between them.

like image 512
Misagh Aghakhani Avatar asked Nov 11 '12 12:11

Misagh Aghakhani


1 Answers

yes you can do it like this:

  <script type="text/javascript" src="jquery-1.1.3.js"></script>
  <script> $113 = jQuery.noConflict();</script>
  <script type="text/javascript" src="jquery-1.4.2.js"></script>

and then use either $113 or $ in your code

like image 194
Kirill Ivlev Avatar answered Nov 15 '22 22:11

Kirill Ivlev