Tsallaka zuwa abun ciki
Justice Tech School

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

How stop an each loop?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.