Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript click counter

## MY HTML
<button id='counter'>Click Me To Count</button>
<span id='result'>1</span>

## MY JAVASCRIPT
let counter = document.getElementById("counter")
let result = document.getElementById("result")
let count = 1

counter.addEventListener("click", () => {
  count += 1
  result.innerHTML = count
})
 
PREVIOUS NEXT
Tagged: #javascript #click #counter
ADD COMMENT
Topic
Name
9+8 =