运行 ❯
获取您
的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 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>