Home >Web Front-end >Front-end Q&A >What is the usage of jquery each

What is the usage of jquery each

WBOY
WBOYOriginal
2022-04-15 16:35:252267browse

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 )

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>

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!

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