W3Schools.com

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


WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE