As we all know, in the jquery syntax, the $ symbol is shorthand for jquery. In some cases, however, you might want to introduce additional JavaScript libraries (such as prototype) on the same page. Because of the short convenience, many libraries also use the $ symbol. To avoid name collisions, jquery provides a noconflict () method to solve this problem. Calling this method gives control of the $ identifier to other libraries.
General mode:
<script src= "Prototype.js" ></script>//1. Libraries outside of jquery (such as prototype)
<script src= "Jquery.js" > </script>//2. Contains the JQuery library to obtain the right to use the $
<script>
jquery.noconflict ();//3. Call Noconflict () method, let out $, To cede control to the first libraries included
</script>
When you need to use the JQuery method when you give up $ control, you cannot use $ to invoke it, using jquery. Or you can replace the $ symbol by defining a new name.
var jq=jquery.noconflict ();
Another trick is to use $ in the Ready () method. Its callback function can receive a parameter, which is the jquery object itself, and can rename jquery to $, which is not a conflict.
Jquery. (document). Ready (function ($) {
//This can be used normally $
})
Of course, the shorthand method is also possible
JQuery (function ($) {
//Here you can use $
})
The above is the entire content of this article, I hope that you learn jquery to avoid conflict methods help.