【问题标题】:jQuery animate return to start statejQuery动画返回开始状态
【发布时间】:2011-12-16 04:00:50
【问题描述】:

我需要第二次点击功能返回 (-=550px)。就像现在一样,图形还在继续。

代码如下:

    $(document).ready(function(){
    $("#busoptbio").hide();
    $("#current").click(function() {
    $("#busoptbio").show();
    $("#busoptbio").animate({left: '+=340px'}, 1200);
    return false;
    });

    $("#busoptbiolnk a").click(function(){
    $("#busoptbio").animate({left: '+=550px'}, 1200);
}, function() {
$("#busoptbio").animate({left: '-=550px'}, 1200);
    return false;
    });
    });

感谢您的帮助。

【问题讨论】:

    标签: jquery function jquery-animate return


    【解决方案1】:
    $("#busoptbiolnk a").click(function(){
        var bio = $("#busoptbio");
        if(bio.hasClass('visible'))
            bio.removeClass('visible').animate({left: '-=550px'}, 1200);
        else
            bio.addClass('visible').animate({left: '+=550px'}, 1200);
    });
    

    【讨论】:

      【解决方案2】:

      你的意思是第二次点击后退吗?

      如果是问题,试试这个

      $("#busoptbiolnk a").click(function(){
          $("#busoptbio").animate({left: '-=550px'}, 1200);
      });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-07-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-16
        • 1970-01-01
        相关资源
        最近更新 更多