setTimeout中包含对象参数时的解决办法

var porssss=document.getElementById("brands_right").getElementsByTagName("p");
for(var i=0;i<porssss.length;i++)
{
porssss[i].style.top="140px";
porssss[i].parentNode.onmouseover=function(){porssss_show(this,30);}
porssss[i].parentNode.onmouseout=function(){porssss_show(this,140);}
}
function porssss_show(element,number){
if(element.childNodes[1].moveThis){clearTimeout(element.childNodes[1].moveThis);}
var pore_top=parseInt(element.childNodes[1].style.top);
if(pore_top==number){return;}
else if(pore_top>number){pore_top-=10;}
else if(pore_top<number){pore_top+=10;}
element.childNodes[1].style.top=pore_top+"px";
element.childNodes[1].moveThis=window.setTimeout(function(){porssss_show(element,number);},5 );//element在此为一个对象,可以使用此方法继续调用。
} 

效果:

转载于:https://www.cnblogs.com/huangyong8585/archive/2012/08/29/2662548.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值