Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use an keyword instead of $ in jquery?

Tags:

jquery

I would like to modify my jQuery to not use $ because using the $ symbol would break other JavaScript libraries (eg. Prototype, Scripaculous). How can I use another variable name instead of the $ symbol?

like image 777
Mohan Ram Avatar asked Dec 02 '22 03:12

Mohan Ram


1 Answers

Use jQuery.noConflict() for compatibility with other libraries, for example:

var $j = jQuery.noConflict();

Then use $j for jQuery, instead of $...or just use jQuery, in which case you don't need to set a variable.

Note: be sure to include jQuery after the other library, so it knows what to give $ back to.

like image 93
Nick Craver Avatar answered Dec 22 '22 00:12

Nick Craver