Home>Article>Web Front-end> How to solve jQuery conflict problem
Solution to the jQuery conflict problem: 1. Release the use rights of the $ symbol in the jQuery framework; 2. Customize an nj to replace the function of $, with statements such as "var nj=jQuery.noConflict(); nj(function(){}”
The demonstration environment of this tutorial: windows7 system, jquery1.2.6 version, Dell G3 computer.
Recommended :jQuery video tutorial
Solution to conflict problem 1:
Take a step back and release the use rights of the $ symbol in the jQuery framework.
In fact, $ is just an alias for jquery. If we need to use another js library other than jquery, we can return control to the library by calling $.noConflict().
Note Point: The release operation must be written before writing other jQuery code
You cannot use $ after releasing, use jQuery instead
jQuery.noConflict(); jQuery(function () { alert("hellow") });
Solution to the conflict problem 2:
Customized access symbols
Customize a nj to replace the function of $
var nj =jQuery.noConflict(); nj(function(){ alert("hello inj 自定义访问符号") });
The above is the detailed content of How to solve jQuery conflict problem. For more information, please follow other related articles on the PHP Chinese website!