Javascript examples for DOM HTML Element:Input Button
Incrementing click count in an HTML button
<html> <head> <style> .btnClass {//from w w w .j av a2 s. c o m width: 96px; height: 48px; font-size: 24px; background: #4FFF8F; } </style> </head> <body> <h2>The Button Element</h2> <button id="btn" class="btnClass">0</button> <script> var btn = document.getElementById('btn'); var i = 0; btn.onclick = function () { i++; btn.innerHTML = i; }; </script> </body> </html>