jQuery and MooTools Conflict

When you have jQuery specific code that is using $, the simplest way is to wrap the code with the following:

// Disable the $ global alias completely
jQuery.noConflict();

// For jQuery scripts
(function($){

// set a local $ variable only available in this block as an alias to jQuery
... here is your jQuery specific code ...

})(jQuery);

// For Mootols scripts
(function($){

// set a local $ variable only available in this block as an alias 
// to Mootools document.id
... here is your Mootools specific code ...

})(document.id);

See the second example on noConflict documentation.

Leave a Comment