I have a set of complex setTimeout() calls that trigger some jQuery animations.
I would like to be able to clear them all without knowing their various refs.
This code will not work – but should illustrate what I’m trying to do…
window.ref = [];
function doAnimation(i) {
$('div').each(function(index) {
window.ref.push(setTimeout('foo(index,i)',index*1000));
window.ref.push(setTimeout('bar(index,i)',index*2000));
});
}
Then clear them with
clearTimeout(window.ref);
Or do it the jQuery way: