Use setInterval function as thread in web page - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setInterval

Description

Use setInterval function as thread in web page

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body onload="myFunction()"> 
      <div id="num">
         <div> 
            <script>
function myFunction()//from  www .j  a  va 2  s  . c  o m
{
   document.getElementById("num").innerHTML=1;
   setInterval(function() {document.getElementById("num").innerHTML=Number(document.getElementById("num").innerHTML)+1},1000);
}

            </script>  
         </div>
      </div>
   </body>
</html>

Related Tutorials