Looping with each
each runs a function for every element. Inside it this is the element, and returning false stops the loop.
Example
$('li').each(function (i, el) {
console.log(i, $(el).text());
});
$.each([1, 2, 3], function (i, n) {
console.log(n);
});Exercise
Loop helper.
$('li').(fn)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.