Home > Article > Web Front-end > A quick solution to the conflict between JQuery's $ and other JS_jquery
As we all know, jQuery is currently the most popular JS package, which simplifies many complex JS programs. JQuery defines the browser DOM tree as $, and uses $ to obtain each child node.
Then, JS plug-ins are not only JQuery, but also prototype.js and other better plug-ins. They also use $. So sometimes when these two JS plug-ins are used at the same time, there will be a conflict of usage rights of $. Now let's see how to resolve this conflict. Please see below:
We all know that JQuery has a function, jquery.noConflict(). Its function is to transfer the control of $. Then we can use jQuery instead of $ to get the dom node
Example:
Method 1:
We can use the noConflict() function to define a shortcut to get the dom node
Method three: