Update button text as you click it - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

Update button text as you click it

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
var number = 1;// w  w w .  j  av  a2 s.  c o m
function IncreaseNumber() {
    document.getElementById('num').innerText = number;
    number++;
}

      </script> 
   </head> 
   <body> 
      <span id="num">0</span> 
      <input type="button" onclick="IncreaseNumber()" value="Change Text">  
   </body>
</html>

Related Tutorials