Click counter | Sololearn: Learn to code for FREE!


Click counter

Can someone tell me how to do a click counter?

5/5/2018 1:10:26 PM

Namikaze Sr.

2 Answers

New Answer


you declare a variable equal to zero: var clicks = 0 you add a button that calls a function: <button onclick=add()>CLICK</button> in the javascript, add a function that adds one value to the variable and displays the number: function add(){ clicks++ document.getElementById(“display”).innerHTML = clicks