Home > Web Front-end > JS Tutorial > body text

jQuery $naming conflict solution summary_jquery

WBOY
Release: 2016-05-16 16:31:36
Original
1457 people have browsed it

I recently encountered a problem where I referenced the jquery library and another js library at the same time. When using $XX to call the js library function, I found that it failed! So I looked for information and found out that it was a jquery naming conflict. Because many JavaScript libraries use $ as function or variable names, jquery does the same. 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(). Below is a collection of five solutions to this problem, one of which you will find useful.

Example 1:

Copy code The code is as follows:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >



Conflict Resolution 1






test---prototype


test---jQuery






Example 2:

Copy code The code is as follows:
Example 3:

Copy code The code is as follows:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >



Conflict Resolution 3






test---prototype


test---jQuery






Example 4:

Copy code The code is as follows:

Copy code The code is as follows:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
">



冲突解决5






test---prototype


test---jQuery





看,原来解决问题的方法可不止一个两个呢,有需要的小伙伴们自己来取吧

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template