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)
}
此功能由“点击”事件调用。但在再次调用该函数后,delayTime
的值不会重新设置为300
。delayTime
值已累计
非常感谢!!
答案 0 :(得分:1)
@gin,
您正在声明变量,但其中一个if条件始终正确执行
以下代码肯定会被执行,为什么它设置为不同的值
删除下面的行并打印,它应该始终打印300
delayTime+=100;
`delyaTime=delyaTime+100;`// equivalent of above code...// you might be already knowing it
答案 1 :(得分:0)
试试这个:
function loadIgInnerPanelMenu(panelNum){
var delayTime;
if($('#igto1 .btMenuShow').length === 0){
$('#igto1 .igInnerPanelBottomMenu').append(loadIgInnerBM(panelNum)).clearQueue();
delayTime = 300;
$('#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).clearQueue();
delayTime = 300;
$(this).stop(false,true).animate({'top':0},delayTime);
delayTime+=100;
});
}
}
alert(delayTime)
}