Exit an instance of a timeout function - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setTimeout

Description

Exit an instance of a timeout function

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(){/*w  w w  .ja va 2  s .  c o  m*/
function work() {
    out.value = new Date()
}
var interval = setInterval(work, 1000)
stopper.onclick = function() {
    clearInterval(interval)
}
    }

      </script> 
   </head> 
   <body> 
      <input id="out"> 
      <button id="stopper">stop</button>  
   </body>
</html>

Related Tutorials