This site is mobile accessible. Press the "Tap Here" button to use a different font-size.



Smartphone icons created by Freepik - Flaticon

JS Timing

Click "Try it". Wait 3 seconds. The page will alert "Hello".

Click "Stop" to prevent the first function to execute.

(You must click "Stop" before the 3 seconds are up.)

// detects the button click to start the timer for myfunction
onclick="myVar = setTimeout(myFunction, 3000)"

// detect button click to clear the timer
onclick="clearTimeout(myVar)"

// execute myFunction
function myFunction() {
  alert("Hello");
}