定时器

作者 Haojen Ma 日期 2015-11-10
JS
定时器

setTimeOut

var timer = setTimeOut(function(){},1000 )//第一个参数是需要执行的程序,第二个是执行前的等待时间

设定一个程序触发后,执行前的等待时间

clearTimeOut

clearTimeOut(timer)

清除 setTimeOut 触发的程序

setTimeInterval

var timer2 = setTimeOut(function(){},1000 )//第一个参数是需要循环执行的程序,第二个参数是循环周期的时间,1000为一秒

设定一个程序隔一定时间触发

clearTimeInterval

clearTimeInterval(timer2)

清除 setTimeInterval 触发的程序