Do Countdown repeatedly and change button text - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

Do Countdown repeatedly and change button text

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head> 
      <title> Bla! </title> 
      <script type="text/javascript">
            var counter = 10;//w w w. jav  a2s . c o  m
            function CountDown(obj) {
                if (--counter < 0) counter = 10;
                obj.innerHTML = "counter=" + counter;
            }
        
      </script> 
   </head> 
   <body> 
      <button onclick="CountDown(this)"> Click to countdown (10) </button>  
   </body>
</html>

Related Tutorials