What is the usage of jquery each

WBOY
Release: 2022-04-15 16:35:25
Original
2205 people have browsed it

In jquery, each is used to traverse specified objects and arrays; you can set the objects or arrays that need to be traversed through parameters, and specify the function for loop execution. The syntax is "$.each(need to be traversed Object or array, function used for loop execution);".

What is the usage of jquery each

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

What is the usage of each in jquery

jQuery.each() function is used to traverse the specified objects and arrays.

Syntax

$.each( object, callback )
Copy after login

The parameters are as follows

object Object type specifies the object or array that needs to be traversed.

callback Function type specifies the function used for loop execution.

The example is as follows:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>123</title>
<script src="js/jquery.min.js"></script>
</head>
<body>
<script>
$(function () { 
$.each([52, 97], function(index, value) {
  alert(index + &#39;: &#39; + value);
});
})
</script>
 
</body>
</html>
Copy after login

Output result:

What is the usage of jquery each

What is the usage of jquery each

Related Video tutorial recommendation: jQuery video tutorial

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

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!