I have a button that disappears by a function after one second. if I click on the button, I want the function will reset and I will get one another second to click. And-I want the button will disappeared if I did not click this second. (if I click in a second, the button doesn't disappeared, if I miss one second, it is disappeared, but if I click, I'll get another second, and so on...)
This is my code:
HTML:
<button id="btn">click
</button>
JavaScript:
let btn = document.querySelector('#btn');
btn.addEventListener('click', ()=>{
click();
})
setTimeout(function click() {
btn.style.display = ('none');
}, 1000);
That code doesn't work. I am an absolute beginner, so any feedback will help me.
If my question is not understood, please write to me in the comments or edit the question.