JSFiddle - React, Tailwind, and code Playground

by madBYK

HTML

<button onclick="delayedAlert();">
    show an alert box after 2 seconds
</button><br>
<button onclick="clearAlert();">Cancel</button>

JavaScript

function delayedAlert()
{
  timeoutID = window.setTimeout(slowAlert, 2000);
}

function slowAlert()
{
  alert("That was really slow!");
}

function clearAlert()
{
  window.clearTimeout(timeoutID);
}