.each() - jQuery API Docs
Description
Iterate through every matched element and execute a function for each.
Syntax
$(selector).each(function(index, element) { ... });
Example
$('.list-item').each(function(i, elem) {
console.log('Item #' + i);
});
Arguments
- function(index, element): Function to execute
- index: Position in the collection
- element: Current DOM element
Returns
jQuery
- Returns the original jQuery object