Home > Article > Web Front-end > jQuery $.each traverses objects and array usage examples_jquery
Through it, you can traverse the attribute values of objects and arrays and process them.
Instructions for use
The effects of each function are not completely consistent depending on the type of parameters:
1. Traverse objects (with additional parameters)
this; //This here points to the current attribute value of the Object in each traversal
p1; p2; //Access additional parameters
}, ['Parameter1', 'Parameter2']);
2. Traverse the array (with attachment parameters)
this; //This here points to the current element of Array in each traversal
p1; p2; //Access additional parameters
}, ['Parameter 1', 'Parameter 2']);
3. Traverse objects (no additional parameters)
this; //this points to the value of the current attribute
Name; //name represents the name of the current property of the Object
value; //value represents the value of the current property of the Object
});
[code]
4. Traverse the array (no additional parameters)
[code]
$.each(Array, function(i, value) {
this; //this points to the current element
i; //i represents the current subscript of Array
value; //value represents the current element of Array
});