运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h2>JavaSript setTimeout()</h2> <p id="demo">I will display when two, four, and six seconds have passed.</p> <script> setTimeout(myTimeout1, 2000) setTimeout(myTimeout2, 4000) setTimeout(myTimeout3, 6000) function myTimeout1() { document.getElementById("demo").innerHTML = "2 seconds"; } function myTimeout2() { document.getElementById("demo").innerHTML = "4 seconds"; } function myTimeout3() { document.getElementById("demo").innerHTML = "6 seconds"; } </script> </body> </html>