.each()

Description: Begin a parallel loop running for all selected elements at once.

- no parameters -

In the instant case all methods in the jQuery chain are invoked in parallel – step by step on each element.


Usage pattern

$('.many').each().wait(event).all().doSome().jQueryStuff();
var values = $('.some').each().attr(name);
var valueArray = $('.some').each().attr(name).all().get();
var valueArray = $($('.some').each().attr(name)).get();

Examples with the parallel each-loop

Example #15: enable continue button only after making choices

In this example the continue button should get enabled only if for each choice the user has selected some value.

The used parallel .each()..all() loop waits for each line until some radio input is selected. Any order of making choices is allowed.

$('.example .choices li')
  .each().children('input').wait('change').all()
  .$('#continue').fadeIn();
  • Color: red, green, blue
  • Size: XS, S, M, L, XL
  • Textile: wool, hemp, synthetic