X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

jQuery Misc each() Method

jQuery Misc Methods jQuery Misc Methods

Example

Alert the text of each <li> element:

$("button").click(function(){
  $("li").each(function(){
    alert($(this).text())
  });
});

Try it yourself »

Definition and Usage

The each() method specifies a function to run for each matched element.

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


Syntax

$(selector).each(function(index,element))

Parameter Description
function(index,element) Required. A function to run for each matched element.
  • index - The index position of the selector
  • element - The current element (the "this" selector can also be used)


jQuery Misc Methods jQuery Misc Methods


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook