count value with timer and set to div - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Div

Description

count value with timer and set to div

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  ww  .j a v a  2s.  c  om
function animateValue(id){
    var obj = document.getElementById(id);
    var current = obj.innerHTML;
    setInterval(function(){
        obj.innerHTML = current++;
    },1000);
}
animateValue('value');
    }

      </script> 
   </head> 
   <body> 
      <div id="value">
         100
      </div>  
   </body>
</html>

Related Tutorials