How to resolve two jquery conflicts?

I have a page that includes jquery for curtain effects and others for a slider. The problem I ran into is that both of my jqueries do not work together. What should I do?

my code example

<!-- for slider --> <script src="images/jquery-latest.js" type="text/javascript"></script> <script src="images/jquery.bxslider2.min.js" type="text/javascript"></script> <script src="images/scripts.js" type="text/javascript"></script> <!-- for curtain --> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> <script src="js/jquery.easing.1.3.js" type="text/javascript"></script> 
+4
source share
4 answers

First of all, try using the current version of jQuery (1.7.2) and see if both scripts work.

If not, consider using something compatible with the current version of jQuery - if something requires jquery 1.3, it has not been updated for a long time.

If you really need both scripts and they require different versions of jQuery, you need to do this as follows:

 <script src=".../jquery-1.3.2.js"></script> <script src="script-that-needs-132.js"></script> <script>var jQuery132 = $.noConflict(true);</script> <script src=".../jquery-1.7.2.js"></script> 

To use the old jQuery, you then wrap the code using it like this:

 (function($){ // here $ points to the old jQuery })(jQuery132); 
+16
source

Delete one of them, preferably this <script type="text/javascript" src="js/jquery-1.3.2.js"></script>

+3
source

you can use

  <script type="text/javascript" language="javascript"> var jq = jQuery.noConflict(); </script> 
+2
source

You cannot / should not include two different versions of jQuery. Stick to one (the very last should be the best choice). If your desired plugin supports only a very old version, for example 1.3, then you should choose a newer version or start messing around in the code.

0
source

All Articles