.repeat(events ,runNow ,callback)

Description: Begin a sequential loop that is triggered by events on any of the selected elements.

events – string
A string containing one or more event types, such as "click" or "submit" or custom event names.
runNow – boolean, optional
whether to start the loop immediately for the first time.
Defaults to false.
callback – function(count…), optional
a method that is called once per loop iteration.
All current iteration counts/events (from inner-most to outer-most loop) are passed as arguments.

The beginning context for each loop iteration depends on the usage of .until().

Examples with the event-triggered loop

Example #14: wait a timeout after each click before blinking

With the concatenation of two .wait()s we achieve a single short blink.

Instead of attaching an event handler explicitly we start an infinite event loop for the "click" event. Repeat loops are always sequential, i.e. the next iteration can start only if the previous one ended. You can see this behavior when double- or triple-clicking the button.

$('.example button').repeat('click').prev()

That text blinks half a second after hitting .