tags:

views:

98

answers:

6

How do I change the $ function in jquery for another word for make it compatible with other framworks

+2  A: 

It's only an alias for jQuery - if $ causes you problems, use jQuery instead.

David M
+8  A: 
jQuery.noConflict();

http://docs.jquery.com/Using_jQuery_with_Other_Libraries

Bob
Tnks very helpfull
+4  A: 

This will un-assign the $ variable

jQuery.noConflict();

But even more useful is being able to reassign the jQuery object to another terse variable, such as

var $j = jQuery.noConflict();

Of course you can make $j anything you want.

Jon Erickson
A: 

You can use the noConflict() method like so:

var myjquery = jQuery.noConflict(true);
myjquery(document).ready( function() {
    // The usual...
} );
Plutor
A: 

use jQuery.noConflict();

if you still want to use the $ shorthand in your jQuery code then you can use a self-invoking anonymous function to do so

(function($) {

    // $ is shorthand for jQuery inside this function :)

})(jQuery);
Russ Cam
A: 

or you can use closure, this way:

jQuery(document).ready(function($){
 $('div') //use regular $
})

However... WHY? Why do you want to load more than once library?

Ionut Staicu
Ok, the thing is that Im using a jquery acordion, it cames with the jquery and the plug in, and every thing its writen with jquery insted of $, but a try to upgrade to a newer version of jquery, but the accordion stop working.
well... the problem may be with the accordion. However, if is a simple accordion, you may try this way: http://dev.iamntz.com/166/jquery-accordion-tutorial :)
Ionut Staicu