ClearInterval running timer - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window clearInterval

Description

ClearInterval running timer

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  ww  w .j a v  a  2s.c  o m
var counter = 0;
    var interval = setInterval(function(){
        counter++;
        if(counter === 5){
            clearInterval(interval);
        }
        console.log("hello");
    }, 2000);
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials