SetInterval and clearInterval
setInterval and clearInterval are global functions of javascript. setInterval method takes call back method and millseconds to call method given milliseconds once.
|
Example
function my_method(){
document.write(Math.random()*1000);
}
/* To start timer using setInterval */
var timer = setInterval("my_method()",3000);
/* To stop timer using clearInterval */
clearInterval(timer);
|
Demo & Output
|