Good morning, we hope you slept well.

Go to the top? Go to the bottom? Send us an email! Follow us on Twitter Grab our feed

Use jQuery with other libraries

We we’re recently doing some custom coding work for a client that wanted some nice jQuery effects but had already used the MooTools Javascript Library in their website.

If you’ve tried using jQuery with other libraries you’ll already know they don’t always play well together straight off. It’s pretty easy to sort this issue with the jQuery.noConflict(); function.

Okay, your typical function would look as follows:

  1.  
  2. // Put your code in document ready
  3.      jQuery(document).ready(function(){
  4. // Do jQuery stuff
  5.        $("div").hide();
  6.      }
  7. );
  8.  

Now the fix, simply add to your function and then replace $ with jQuery.

  1.  
  2. // Add the noconflict
  3. jQuery.noConflict();
  4.      
  5. // Put your code in document ready
  6.      jQuery(document).ready(function(){
  7. // Do jQuery stuff using
  8.        jQuery("div").hide();
  9.      }
  10. );
  11.  

It really is as simple as that. Your Javascript libraries should all get along now.




Leave a comment:



By submitting a comment here you grant iKreativ a perpetual license to reproduce your words, name and/or website in attribution. Inappropriate comments will be removed at admin's discretion.