7

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.

1
  • i think you must declare a noConflict variable instantly after each jQuery script tag in inline script tag. Commented Nov 11, 2012 at 12:43

1 Answer 1

20

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you Kirill I,m actually using wordpress and one jquery file is in the header.php and another on is in the another php file.When I browse my website some of the act in my site dose not work properly.
@MisaghAghakhani you need to change all document.ready in existing code prior to adding 1.4 from $(document).ready(function(){/* code*/} to $113(document).ready(function($){/* code*/}. You will still be able to use $ inside that wrapper...or upgrade all previous code which likely has a lof @ used in selectors which is a protocol that was deprecated

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.