How do you loop over elements with jQuery each()?
<ul><li>One</li><li>Two</li><li>Three</li></ul>
$('li').each(function (i) {
console.log(i + ': ' + $(this).text());
if (i === 1) return false; // break
});
Console output
0: One
1: Two
See jQuery each().
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |