enavu webdevmania tutsvalley psdestination
visit the enavu network
45 Comments Article Title Overlay Article Title

Using multiple versions of jQuery on the same page

There are few reasons why you would want to disable the menu we get after clicking right mouse button. One of them is if you want to show your own menu. In this daily tip we will disable that default menu using jQuery.

DZoneDiggDesign FloatDeliciousBlinklistRedditFacebookGoogle BuzzTwitterStumbleUponTumblrShare
You might be wondering why would you want to use different version of jQuery on the same page, why not just use the newest version, right? Well in my freelancing career as a web developer i stumbled upon few websites that are using jQuery ver 1.2.x and when i changed it to 1.3.x some of the plugins stopped working, so i needed to have both versions on a same page. This is how it’s done…

<script type='text/javascript' src='js/jquery_1.3.js'></script>

<script type='text/javascript'>

 var $jq = jQuery.noConflict();

</script>

<script type='text/javascript' src='js/jquery_1.2.js'></script>

And this way when you want something made with the new version of jquery instead of the “$” use “$jq”.

Example:

$jq('.selector').live('click', function(){
    //do something
});

You can also use this trick if there is prototype on the site, because it’s also using the $.

Ok, that’s it for today, i hope this little tip helped you or will help you in future.

Related posts:

  1. Easy Unobstructive jQuery Print Page Tutorial
  2. Use HTML5 Placeholder Input Attribute Today using jQuery!
  3. Automatic input field focus on page load
  4. Top 10 jQuery Snippets (including jquery 1.4)
  5. Little app to help you code 10+ times faster

Slobodan Kustrimovic

This author has yet to fill his BIO.

Did you absolutely LOVE this article... share it!

Comments

  • Wow, you just saved me so much hassle this is without doubt one of the most useful code snippets I have come across.

  • Glad to be helpful :)

  • thanks, and compliments for all the articles

  • You can check here with demo example.

  • http://aspnetnova.blogspot.com/2009/12/jquery-multiple-version-of-jquery-in.html
    Demo here with source.

  • nice …i m searching the same for more than a week. now got a solution.. thank you guys …

  • @alen – Glad to help :)

  • If you were here I’d kiss you!

    Had left this till last on a site I’ve just done and wasn’t looking forward to the hours of debugging I was expecting.

    Fixed in 5 mins!

    TVVVVVVM

  • Hi there,

    Can somebody help me by telling me how can i use these 2 scripts in one page :

    window.addEvent(‘domready’, function(){check = new FormCheck(‘third’, {
    display : {
    fadeDuration : 500,
    errorsLocation : 1,
    indicateErrors : 1,
    showErrors : 1
    }
    })});

    and :

    ddsmoothmenu.init({
    mainmenuid: “smoothmenu1″, //menu DIV id
    orientation: ‘h’, //Horizontal or vertical menu: Set to “h” or “v”
    classname: ‘ddsmoothmenu’, //class added to menu’s outer DIV
    //customtheme: ["#1c5a80", "#18374a"],
    contentsource: “markup” //”markup” or ["container_id", "path_to_menu_file"]
    })

    ddsmoothmenu.init({
    mainmenuid: “smoothmenu2″, //Menu DIV id
    orientation: ‘v’, //Horizontal or vertical menu: Set to “h” or “v”
    classname: ‘ddsmoothmenu-v’, //class added to menu’s outer DIV
    //customtheme: ["#804000", "#482400"],
    contentsource: “markup” //”markup” or ["container_id", "path_to_menu_file"]
    })

    Thanks

  • OMG thank you, you are a live saver!!!!!!!!!!!!! :)

  • I have the opposite issue. I want the $ to reflect the LATEST version of JQuery and assign, say, $jq to an OLDER version. Is this possible?

  • I LOVE YOU!!! THANK’s, thank’s, thank’s,thank’s,thank’s,thank’s,thank’s,thank’s….!!!!

  • gangelo im just guessing but didn’t switching the versions from top to bottom and bottom to top work? What im saying is, did you try putting the older version first and then the newer one??

  • nice. we tried this and this is working

  • I do not have a clue how to get it work..
    Can someone give real examples with a zip file or something? I have nivo slider and flexgrid.. I can have only the one of those working.

    Is obvious that I am really novice, please direct me..

    Thank you!

  • THANK YOU!!! THANK YOU!!! THANK YOU!!! THANK YOU!!! THANK YOU!!! THANK YOU!!! THANK YOU!!! THANK YOU!!! THANK YOU!!! THANK YOU!!! THANK YOU!!! THANK YOU!!! THANK YOU!!! THANK YOU!!!

  • Thank u so much……

  • You are my hero. Seriously. Had I found something like this 4 hours ago… well, I guess I’d have those 4 hours of my life back.

    Did I mention that you’re my hero?

  • trick works but some of the properties is not working
    in my case i using transparent slidemenu style but after using this trick transparency gone,instead gray type colour is coming !!

  • Works perfectly for me.

    Thank you!!

  • Thanks a ton… saved my day.. worded :D :D

  • I am having the same problem as GANGELO.

    I placed the older version first and set it to $jq. I then declare the latest version.

    PROBLEM:
    I am using v1.2.6 throughout the site…. there are some scripts that need to use v1.5.2. Everything seems fine, up until 1.2.6 is used. From that point on… seems to forget about 1.2.6

    PLEASE ADVISE

  • CORRECTION!

    I am having the same problem as GANGELO.

    I placed the older version first and set it to $jq. I then declare the latest version.

    PROBLEM:
    I am using v1.5,2 throughout the site…. there are some scripts that need to use v1.2.6 Everything seems fine, up until 1.2.6 is used. From that point on… seems to forget about 1.5.2

    PLEASE ADVISE

  • Man, you are awesome! THANKS ALOT!

  • love you from the bottom of my heart

  • THANK YOU! I’ve been looking online for HOURS! Your code snippet was color coded, simple, and straight to the point. Very nice and thanks again!

  • thanks you saved my job :)

  • Thank you very much for this, you’re a lifesaver!

  • thxxxxxxxxxxxxxxxx <3

  • thank you verey much :) :)
    you have done a good job….i was about to use a link on another page to do the job…now i can do it on the same page……

  • This has saved my day. Excellent solution.

  • same problem.
    I am using 1.4.1
    I set them all to the method described above.
    however, even adding in 1.5.1 breaks all of the 1.4.1 plugins. really odd. Went so far as to apply this method to ALL 1.5.1 and 1.4.1 scripts. same deal, no go…

  • Thanks so much, works great!

  • Great!!! Thank you so much!!! Let me know if you come to Milwaukee, Wisconsin and I’ll invite you a beer!

  • Amazing! Saved a lot of time and frustration. Thanks!

  • Thanks to save my time. And this is really wonderful thing you have showed us. Thanks a lot.

  • Thanks for your I got the result.

  • Phew saved me a few more hours of frustration!

  • Thank you!! Solved a problem for me!! :)

  • now got a solution……….thanksssss

  • I have found many many blogs about this jQuery multiversion.

    But you did better! Thank you very much. My problem solved!

  • thanks man! real time saver.

  • Works perfectly for me.

    Thank you so mush………..

  • It is working nice.

    Thnak You!!

  • Thank you soooo much…you really helped me and saved alot…

Leave your own!

Sponsors

freedcamp free project management

Popular Articles

fzilla file hosting