Posts

Showing posts from August, 2017

Counter Button

Image
Description : It is a javascript based button counter. In this we declare global variable counter which counts the button clicks. The updated counter value is displayed as a text in heading. Example: 0 Counter Button Html Code <!DOCTYPE html> <html> <head> <title>Counter Button</title> <script> var counter = 0; function countBtnClicks() { counter = counter + 1; document.getElementById("txtBtnCount").innerHTML = counter; } </script> </head> <body> <h2 id="txtBtnCount">0</h2> <button onclick="countBtnClicks()">Counter Button</button> </body> </html>