JavaScript setInterval 方法进行函数延迟执行

设置程序延迟 3 秒后执行setInterval(function(){alert("Hello")},3000);Demo 代码如下:[code]

Click the button to wait 3 seconds, then alert "Hello".

After clicking away the alert box, an new alert box will appear in 3 seconds. This goes on forever...

Try it function myFunction() { setInterval(function(){alert("Hello")},3000); }
  </script>
[/code]程序运行结果为: ![](https://cdn.isharkfly.com/com-ossez-www/data/attachment/forum/201303/25/123822m45ow88wv5umku45.jpg)