开发者

The variable value doesn't set back in jquery animate function!

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 ver开发者_运维百科y much!!


@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

delayTime+=100; 
`delyaTime=delyaTime+100;`// equivalent of above code...// you might be already knowing it


try this:

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) 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜