Execute function every nth second

Posted by timkl on Stack Overflow See other posts from Stack Overflow or by timkl
Published on 2010-03-24T22:38:24Z Indexed on 2010/03/24 22:43 UTC
Read the original article Hit count: 275

Filed under:
|

Total JacaScript n00b question right here:

I've made this snippet that clicks a link after 10th second:

function timeout() {
    window.setTimeout(function() {
     $('img.left').click();
    }, 1000);
    setTimeout("timeout()", 1000); 
}
timeout();

My question is, how do I execute this function every 10th second, instead of just once?

Is this the best way to do this, or is there some kind of nifty jQuery method that you prefer?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery