jQuery滑出导航

时间:2012-02-25 16:42:26

标签: jquery mobile navigation boolean tablet

我在这里做错了什么。动画滑出导航,但无法滑回。

$(document).ready(function() {
$('.navLink').click(function(e){
    var navCount=0;
    if (navCount==0) {
        $('.navigation').stop().animate({'marginLeft':'0px'}, 200);
        $('#waitingPage').stop().animate({'marginLeft':'230px'}, 200);
        var navCount=1;
    }else if (navCount==1){
        $('.navigation').stop().animate({'marginLeft':'-230px'}, 200);
        $('#waitingPage').stop().animate({'marginLeft':'0px'}, 200);
        var navCount=0;
    };
    });
});//END ready

1 个答案:

答案 0 :(得分:1)

在我看来,如果你使用.toggle()

,你的代码可能会简单得多

类似的东西:

$('.navLink').toggle(function(){

    // animation code

}, function(){

    // animation code

});