Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h2>JavaScript Timing</h2> <p>Click "Try it". Wait 3 seconds. The page will alert "Hello".</p> <p>Click "Stop" to prevent the first function to execute.</p> <p>(You must click "Stop" before the 3 seconds are up.)</p> <button onclick="myVar = setTimeout(myFunction, 3000)">Try it</button> <button onclick="clearTimeout(myVar)">Stop it</button> <script> function myFunction() { alert("Hello"); } </script> </body> </html>