源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> </head> <body> <p>點擊按鈕,等待 3 秒會彈出 "Hello"。</p> <p>在彈出的對話框中點擊 “確定”, 3 秒後會繼續彈出。如此循環下去...</p> <button onclick="myFunction()">點我</button> <script> function myFunction() { setInterval(function(){ alert("Hello"); }, 3000); } </script> </body> </html>
運行結果