執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,暗/亮
前往 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>