Track Timer and display its value - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setInterval

Description

Track Timer and display its value

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from   w w  w  .  ja  v  a  2 s  .  c o m
var num = 0.00;
window.setInterval(function () {
    timer();
}, 100);
function timer() {
    num = ((num * 100) + 1) / 100;
    document.getElementById("timer").innerHTML = num.toFixed(2);
}
    }

      </script> 
   </head> 
   <body> 
      <div id="timer">
         0.000
      </div>  
   </body>
</html>

Related Tutorials