Dealing with compatibility issues with different versions of jquery

Source: Internet
Author: User
Tags jquery library

As we all know, there are a lot of jquery version, and some versions of the conflict is very obvious, there are some very useful web-based plug-ins are written in version a, but to achieve the other features must be used in version B. So it is important to live in peace between versions.

1. Here is a function that can be very smooth, very simple to solve the problem.

<script type= "Text/javascript" src= "jquery.js" ></script><script type= "Text/javascript" >var j = Jquery.noconflict (true); </script><script type= "Text/javascript" src= "Jquery-1.7.js" ></script> <script type= "Text/javascript" >$ ("document"). Ready (function () {alert ("FAF");}) J ("Document"). Ready (function () {alert ("FAF");}) </script>

Run this function to transfer the use rights of $ to another jquery library, which avoids collisions between $ objects in different jquery versions.

After running this function, you can only use J to access the first jquery library. For example, where you want to use $ ("div p"), you must change to J ("Div p"). Another jquery library, normally accessed using $.

Note: This function must be run after the jquery file is imported and before the other person's jquery library is imported. If you change a jquery reference object that references a plug-in, the JQuery object reference inside the plugin must be modified to be consistent.

2. Use jquery migrate to restore features that have been deleted or changed in a jquery version to resolve version conflict issues.


Dealing with compatibility issues with different versions of jquery

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.