jQuery.each()Method

jQuery 杂项方法jQuery Miscellaneous Methods

Examples

Iterate over array elements

$(function () { $.each([52, 97], function(index, value) { alert(index + ': ' + value); }); })

Try it yourself »

Definition and Usage

The jQuery.each() function is used to iterate over the specified objects and arrays.


Syntax

$.each( object, callback )

Parameter Description
object Object type - Specifies the object or array to be traversed.
callback Function type - Specifies the function to be executed for the loop.


实例

More Examples

Traverse an object
Traverse object properties.

Traverse an array
Traverse an array, displaying both keys and values.

Traverse an array
Traverse an array, accessing the iterated elements and their index values.

Traverse an element
Iterate over an element's properties, accessing both its keys and values.


jQuery 杂项方法jQuery Miscellaneous Methods

Other Extensions