Javascript examples for Browser Object Model:Window setInterval
Stop thread with count flag
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w .j av a 2s. co 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>