下面的代码执行后点击按钮会延迟3秒钟弹出一个警告框,主要演示了setTimeout的使用方法
<!DOCTYPE html> <html> <body> <p>75271.com Click the button to wait 3 seconds, then alert "Hello".</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { setTimeout(function(){alert("Hello")},3000); } </script> </body> </html>