定时器

查询定时器有两种:

1,一种是执行一次setTimeout(function(){},Time)

    在执行一次其中的事件,然后延迟一段事件,在执行其他操作

2,一种是执行一次setInterval(function(){},Time)

    每隔Time这段时间,执行一个事件,不断重复

 

 

清除事件:

function time(){

   console.log(hi);

}

var timer1 = setTimeout( time(),Time)

var timer2 = setInterval( time(),Time)

clearTimeout(timer1) 清除已设置的setTimeout对象
clearInterval(timer2) 清除已设置的setInterval对象

 

 

 

 

posted @ 2016-12-21 09:50  言笑  阅读(96)  评论(0编辑  收藏  举报