Answers

Question and Answer:

  Home  JQuery Programmer

⟩ Explain the each() function?

The each() function specify the function to be called for every matched element.

Syntax :

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

1. "index" is the index position of the selector.

2. "selector" specifies the current selector where we can use "this" selector also.

3. In the case when we need to stop the each loop early then we can use "return false;"

For example

$("#clickme").click(function()

{

$("li").each(function()

{

document.write($(this).text())

});

});

 225 views

More Questions for you: