Analytic jquery coexists with other JS (Prototype) libraries

Source: Internet
Author: User
The solution of jquery and other JS (Prototype) library conflict is very simple, is the use of jquery jquery.noconflict () function, the following small series for you to introduce, the need for friends can refer to the

First, after running this function, you can restore the use of alias $, in the scope of this function will still be $ as the alias of JQuery to use.
jQuery Code:

Copy Code code as follows:
Jquery.noconflict ();
(function ($) {
$ (function () {
Use $ as a jQuery alias code
});
}) (JQuery);
Code that uses $ as an alias based on other libraries


Two, after running this function, you can create a new jquery alias to replace the original jquery alias $ to use.
jQuery Code:

Copy Code code as follows:
var j = jquery.noconflict ();
Code that uses the new alias JQuery
J ("Div p"). Hide ();
Code that uses $ as an alias based on other libraries
$ ("content"). Style.display = ' None ';


Note: This function must be used after you import the JQuery file and before importing another library that is causing the conflict.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.