I've created 3 buttons, when you push one of them, indicates how many times you have clicked on that button.
I succeeded in making the button work properly. But the reset button I made is broken, which is the issue.
when you click the rest button it's going to '0' but after starting the button press again counting starts from '2' or '3', not from the number '1'.
please help me to sort this matter.
let btns=document.querySelectorAll('.box');
let reset=document.getElementById('rest');
btns.forEach(btn => {
btn.addEventListener('click', () => {
btn.innerText= ++ btn.value;
});
});
reset.addEventListener('click', ()=>{
btns.forEach(btn => {
btn.innerText= 0;
});
});
button{
height: 100px;
width: 100px;
}
<button class="box" value="0">0</button>
<button class="box" value="0">0</button>
<button class="box" value="0">0</button>
<button id="rest">Reset</button>