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);".
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
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 + ': ' + value); }); }) </script> </body> </html>
Output result:
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!