JSFiddle - React, Tailwind, and code Playground
by raycn
HTML
<button onclick="delayedAlert()">delay</button>
<button onclick="clearAlert()">clear</button>
<button onclick="console.log(timeoutID);">id</button>
JavaScript
var timeoutID;
function delayedAlert() {
timeoutID = window.setTimeout(slowAlert, 2000);
}
function slowAlert() {
alert("That was really slow!");
}
function clearAlert() {
window.clearTimeout(timeoutID);
}