变量值不会在 jquery animate 函数中设置回来!
function loadIgInnerPanelMenu(panelNum){
var delayTime = 300;
if($('#igto1 .btMenuShow').length === 0){
$('#igto1 .igInnerPanelBottomMenu').append(loadIgInnerBM(panelNum)).animate({'top':419},'fast',function(){}).addClass('btMenuShow').find('.btMenu').each(function(){
$(this).stop(false,true).animate({'top':0},delayTime);
delayTime+=100;
});
}
else{
// using inuse to prevent the botton quick switch
if(inuse === false){
$('#igto1 .igInnerPanelBottomMenu').append(loadIgInnerBM(panelNum)).find('.btMenu:gt(3)').each(function(){
$(this).stop(false,true).animate({'top':0},delayTime);
delayTime+=100;
});
}
}
alert(delayTime)
该函数由“click”事件调用。但是
再次调用该函数后,delayTime
的值并未设置回 300
。delayTime
值已累计。
非常感谢!!
function loadIgInnerPanelMenu(panelNum){
var delayTime = 300;
if($('#igto1 .btMenuShow').length === 0){
$('#igto1 .igInnerPanelBottomMenu').append(loadIgInnerBM(panelNum)).animate({'top':419},'fast',function(){}).addClass('btMenuShow').find('.btMenu').each(function(){
$(this).stop(false,true).animate({'top':0},delayTime);
delayTime+=100;
});
}
else{
// using inuse to prevent the botton quick switch
if(inuse === false){
$('#igto1 .igInnerPanelBottomMenu').append(loadIgInnerBM(panelNum)).find('.btMenu:gt(3)').each(function(){
$(this).stop(false,true).animate({'top':0},delayTime);
delayTime+=100;
});
}
}
alert(delayTime)
}
this function is called by a 'click' event .but the value of delayTime
doesn't set back to 300
after the function was called again.The delayTime
value was cumulated.
Thank you very much!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@gin,
您正在声明变量,但 if 条件之一始终正确执行
,以下代码肯定会执行,这就是为什么它设置为不同的值
删除下面的行并打印,它应该始终打印 300
@gin ,
you are declaring the variable but one of the if conditions are always executing right
the following code gets executed for sure and whats why it is setting to a different value
remove the below line and print , it should always print 300
试试这个:
try this: