setTimeOut、setInterval与clearInterval函数

1.setTimeOut

在指定毫秒数后调用函数或计算表达式,函数或计算表达式只执行一次

setTimeout("alert('5 seconds!')",5000)

2、setInterval

按照指定的周期来调用函数或计算表达式

setInterval("alert('hello')",1000)

3、clearInterval

可以取消setInterval的设置,setInterval返回的值可以作为clearInterval方法的参数

var helloStr = setInterval("alert('hello')",1000);
clearInterval( helloStr);

  

  

posted @ 2017-07-05 09:57  慵懒的小猪  阅读(204)  评论(0编辑  收藏  举报