## 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
})
<!-- HTML ->
<button id="btn-count">Count</button>
<p id="result"></p>
// JavaScript
const btnCount = document.getElementById('btn-count');
btnCount.addEventListener('click', () => {
let counter = 0;
counter++;
document.getElementById('result').innerText = counter;
});
//simple counter in javascript
// this is button element variable
const button = document.querySelectorAll(".btn")
//this variable for display counter number
const h3 = document.querySelector(".counter")
//Count variable
let count = 0;
//foreach method
button.forEach((btn) => {
//event listener function
btn.addEventListener("click", (e) => {
//event targeting element
let target = e.currentTarget
//condition for counter variable
if (target.innerText == "reset") {
count = 0;
}
else if (target.innerText == "next") {
count++;
}
else if (target.innerText == "prev") {
count--;
}
//text contains according to the if condition
h3.innerHTML = count;
})
})