Knowledge Walls
John Peter
Pune, Maharashtra, India
How to use setInterval and clearInterval methods in javascript with Example
3533 Views
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 
Best Lessons of "Good Javascript Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details