delay
1.6.0

delay(seconds[, arg...]) -> Number

Schedules the function to run after the specified amount of time, passing any arguments given.

Behaves much like window.setTimeout. Returns an ID that can be used to clear the timeout with window.clearTimeout before it runs.

To schedule a function to run as soon as the interpreter is idle, use Function#defer.

Examples


// before:
window.setTimeout(function() {
 Element.addClassName('foo', 'bar'); }, 1000);

// after:
Element.addClassName.delay(1, 'foo', 'bar');


// clearing a timeout
var id = Element.hide.delay(5, 'foo');
window.clearTimeout(id);