Javascript – Call js-function using JQuery timer

javascriptjquery

Is there anyway to implement a timer for JQuery, eg. every 10 seconds it needs to call a js function.

I tried the following

window.setTimeout(function() {
 alert('test');
}, 10000);

but this only executes once and then never again.

Best Answer

You can use this:

window.setInterval(yourfunction, 10000);

function yourfunction() { alert('test'); }