English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
As you know, jQuery uses the dollar sign ($) as a shortcut or alias for jQuery.
Just like jQuery, many JavaScript libraries use $ as a function or variable name.
If two different libraries use the same shortcut, one of them may stop working.
Fortunately, jQuery provides a special$.noConflict()method to handle this situation.
jQuery $.noConflict()The method releases jQuery's specification of the $ variable so that other scripts can use it.
Of course, you can still use jQuery, just write the full name instead of the shortcut:}}
$.noConflict(); jQuery(document).ready(function(){ jQuery("button").click(function(){ jQuery("p").text("jQuery runs perfectly!!!"); }); });Test and See‹/›
This method can also be used to specify a new custom name for the jQuery variable.
The following example creates an alias instead of using jQuery throughout the rest of the script:
let jq = $.noConflict(); jq(document).ready(function(){ jq("button").click(function(){ jq("p").slideToggle(); }); });Test and See‹/›
For complete references to other methods, please visit ourjQuery Other References>.