Easy Tutorial
❮ Jquery Ref Events Html Escapeselector ❯

jQuery Miscellaneous each() Method

jQuery Miscellaneous Methods

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 run for each matched element.

Tip: Returning false can be used to stop the loop early.


Syntax

Parameter Description
function (index,element) Required. A function to run for each matched element. index - The index position of the selector.<br><br>element - The current element (also accessible using "this" selector).

jQuery Miscellaneous Methods

❮ Jquery Ref Events Html Escapeselector ❯