How to wait for some event on each element in the right sequence?

Compact syntax with timing methods:

1
$('.many').each($).wait(event).all().doSome().jQueryStuff();

Compare this to the old way with more syntactic fluff:

1
2
3
4
5
6
7
8
9
var $elems = $('.many');
function trigger() {
   if ($elems.index(this) >= $elems.length-1) {
      $elems.doSome().jQueryStuff();
   } else {
      $elems.eq($elems.index(this)+1).one(event,trigger);
   }
}
$elems.first().one(event,trigger);

Similar patterns with closed loops

Similar patterns with sequential loops