Call clearTimeout() via another function - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window setTimeout

Description

Call clearTimeout() via another function

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <button onclick="start()">Try it</button> 
      <button onclick="end()">click me</button> 
      <script>
   var fun;/*ww w .j av  a  2 s . c  om*/
   function start() {
      fun = setTimeout(function(){ console.log("Hello"); }, 3000);
   }
   function end(){
      clearTimeout(fun);
   }
   
      </script>  
   </body>
</html>

Related Tutorials