Home >Database >Mysql Tutorial >What is jquery migrate

What is jquery migrate

WBOY
WBOYOriginal
2022-04-15 11:50:353436browse

jquery migrate is an auxiliary plug-in for application migration. It is an auxiliary plug-in for high-level versions to be compatible with low-level versions. This plug-in can solve the problem of incompatibility between old and new code after jquery upgrade. Simply put, it converts unsupported functions Write it down again to support it.

What is jquery migrate

The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.

What is jquery migrate

jQuery Migrate is an application migration auxiliary plug-in. It is an auxiliary plug-in for high-level versions to be compatible with low-level versions.

For example, if the jQuery version is 1.x and you plan to upgrade to 3.x, you can delete the 1.x version on the page and replace it with the 3.x version. If there is a script error, introduce jquery-migrate The plug-in is used to be compatible with lower versions, and also displays the solution for replacing lower version methods with newer version methods.

jQuery migrate (transfer, transition) This package solves the incompatibility problem between the old and new code after jquery upgrade. Just rewrite the unsupported functions and support them.

There are differences between jQuery versions. For example, version 1.9 no longer supports live(), die(), toggle(), sub(), $.browser, etc. To use a version after 1.9 without changing your website code, you need to use jQuery migrate (transfer, transition),

Example:

<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
 <title>test</title>  
 <script type="text/javascript" src="jquery-1.6.1.js"></script>
 <script type="text/javascript">
 $(document).ready(function(){
  $("button").click(function(){
  alert($("li").size());
  });
 });
 </script>
</head>
<body>
<button>测试按钮</button>
<ul>
<li>Coffee</li>
<li>Milk</li>
<li>Soda</li>
</ul>
</body>
</html>

Click the button and "3" will pop up.

Replace

with

At this time, click the button and a script error will be displayed in the Chrome browser developer window:

What is jquery migrate

$(...).size is not a function

Introduce

Click the button and "3" will pop up normally.

It also prompts that the size method is deprecated and uses length instead:

jQuery.fn.size() is deprecated and removed; use the .length property

What is jquery migrate

Change $("li").size() to $("li ").length, remove jquery-migrate-3.0.1.js, click the button, and "3" will pop up.

The migration method is completed.

Recommended related video tutorials: jQuery video tutorial

The above is the detailed content of What is jquery migrate. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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