I have this function that runs for several seconds with the use of setTimeout. This function is ran when a button is clicked.
function complete(
Assuming you've used addEventListener to attach the click event to the button, you could remove the listener while timeouts are in progress:
function complete() {
var div = document.getElementById('log'),
button = this;
this.removeEventListener('click', complete);
setTimeout(function(){...});
:
setTimeout(function(){...});
// If you later want to make the button clickable again, just uncomment the line below:
// setTimeout(function () {button.addEventListener('click', complete);}, 10000);
}