Javascript examples for Browser Object Model:Window setInterval
Count up with delay via setInterval()
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w ww . j a va 2s . c o m var i = 0; theLabel = document.getElementById("counter"); var interval = setInterval(function(){ if (i == 100) clearInterval(interval); theLabel.innerHTML = i; i++; }, 1000); } </script> </head> <body> <div id="counter"></div> </body> </html>