Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
Click counter
Can someone tell me how to do a click counter?
1 Resposta
0
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