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

How to let jQuery coexist with other JavaScript libraries to avoid conflicts_jquery

WBOY
Release: 2016-05-16 17:07:44
Original
952 people have browsed it

In order to solve the conflict between the $() function in jQuery and other JavaScript libraries, it is necessary to cancel jQuery's $() function. For this purpose, jQuery provides the following method:

Copy code The code is as follows:

//Cancel the $() function in jQuery
jQuery.noConflict();

Change the above The bold code is placed in the first line of JavaScript code. This line of code will cancel jQuery's $() function

Note: In fact, it only cancels the $() alias of jQuery() function, so we You can still use jQuery to replace the original $().

In addition, writing jQuery() multiple times is also very cumbersome. jQuery also allows developers to specify their own aliases for jQuery(), as shown in the following code:
Copy code The code is as follows:


< /div>



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