onclick JavaScript

I add button that counts how many clicks did you clicked I learned how to do it in JavaScript thx for mrw for helping me <3


const count1 = document.getElementById("count1");
let clicks = 0;


function countClick() {
   clicks += 1
   count1.textContent = clicks;
   console.log(clicks)
}

This is the code of JavaScript we put the clicks 0 and if you press the button its gonad +1 like clicks +=1.

2 thoughts on “onclick JavaScript”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top