defer
1.6.0
defer(arg...) -> Number
Schedules the function to run as soon as the interpreter is idle.
A “deferred” function will not run immediately; rather, it will run as soon as the interpreter’s call stack is empty.
Behaves much like window.setTimeout
with a delay set to 0
. Returns an ID that can be used to clear the timeout with window.clearTimeout
before it runs.
Examples
function hideNewElement() {
$('inserted').hide();
};
function insertThenHide(markup) {
$('container').insert(markup);
// IE needs a moment to add the new markup
// to the DOM tree
hideNewElement.defer();
}
insertThenHide("<div id='inserted'>Lorem ipsum</div>");