I have this function that runs for several seconds with the use of setTimeout. This function is ran when a button is clicked.
setTimeout
function complete(
for stop running timer you have to clear him
var stopTimer; function someFunction() { stopTimer= setTimeout(function(){ console.log("something done"); }, 3000); } function stopFunction() { clearTimeout(stopTimer); }