jQuery Traversal - each() Method
Example
Output the text of each li element:
$("button").click(function() { $("li").each(function() { alert($(this).text()); }); });
Definition and Usage
The each() method specifies a function to be executed for each matching element.
Tip:Returning false can be used to stop the loop early.
Syntax
$().each(function(index, element))
Parameters | Description |
---|---|
function(index, element) |
Required. Specify the function to be executed for each matching element.
|