treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Any way I can use two different versions of jquery on one page?

  • Hey guys, have just run into a problem on a new site, I know that one version of jQuery cancels out another, but I need the two too work, is this possible? if so how? thankyou, Luke
  • Why do you need both to run? Could you not just let the later version of the two do the work?
  • No idea why you'd want that, and I definitely not recommend it (I'm sure there will be conflicts!), but you might want to try this. Say you're loading two jQuery library files (jquery-1.js and jquery-2.js).

    1. At the end of jquery-1.js, add this line: j1$ = jQuery.noConflict();

    2. At the end of jquery-2.js, add this line: j2$ = jQuery.noConflict();

    3. To do anything with the first library, instead of something like $('#blah').show();, use j1$('#blah').show();

    4. To do anything with the second library, instead of something like $('#blah').show();, use j2$('#blah').show();

    Haven't tested it myself, but see if it works for you.
  • Sorry should have explained better in my first post, I'm wanting to use jparallax, and it only works well with 1.2.6. Of course im wanting to use the latest version with everything else. Ill be sure to try that out after work. Thanks
  • The version of jParallax on GitHub supports version 1.6.1
    https://github.com/stephband/jparallax

    I'm sure it would work with the latest version, it just looks like it hasn't been updated in a while
  • why thankyou :D never saw that :)