I'd like this function to reset the counter every time there's a change in the text input
This is my current JavaScript code:
let counter = 0
const button = document.getElementById('updatePic')
button.addEventListener('click', getimages)
button.addEventListener('click', function() {
counter++;
console.log(counter);
if ( document.getElementById("dateUserInput").innerHTML /*reset everytime theres a new input*/ ){
counter = 0
}
});
Every time the button gets clicked the counter increments (counter++).
And I want the counter to reset every time the text changes in #dateUserInput input.
What's the most efficient way to achieve this?