码迷,mamicode.com
首页 > 其他好文 > 详细

clearInterval() 函数详解

时间:2017-03-22 15:07:30      阅读:832      评论:0      收藏:0      [点我收藏+]

标签:eth   name   order   cti   border   use   doc   设置   size   

定义和用法

clearInterval() 方法可取消由 setInterval() 设置的 timeout。

clearInterval() 方法的参数必须是由 setInterval() 返回的 ID 值。

语法

clearInterval(id_of_setinterval)

 

 

参数 描述
id_of_setinterval 由 setInterval() 返回的 ID 值。

 

 

实例

window.onload=function(){
var aLi=document.getElementsByTagName(‘li‘);
for(var i=0; i<aLi.length; i++){
aLi[i].onmouseover=function(){
var oSubNav=this.getElementsByTagName(‘ul‘)[0];
if(oSubNav){
var This=oSubNav;
clearInterval(This.time);
This.time=setInterval(function(){
This.style.height=This.offsetHeight+16+"px";
if(This.offsetHeight>=120)
clearInterval(This.time);
},30)
}
}
//鼠标离开菜单,二级菜单动画收缩起来。
aLi[i].onmouseout=function(){
var oSubNav=this.getElementsByTagName(‘ul‘)[0];
if(oSubNav){
var This=oSubNav;
clearInterval(This.time);
This.time=setInterval(function(){
This.style.height=This.offsetHeight-16+"px";
if(This.offsetHeight<=0)
clearInterval(This.time);
},30)
}
}
}
}

 

clearInterval() 函数详解

标签:eth   name   order   cti   border   use   doc   设置   size   

原文地址:http://www.cnblogs.com/milkytea/p/6599901.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!