【问题标题】:jquery animate position in percentagejQuery动画位置百分比
【发布时间】:2012-06-16 10:35:43
【问题描述】:

我如何确定百分比位置?

    $(document).ready(function(){
      $("#button").toggle(function(){
        $("#slide").animate({top:-100%},1000);
      },function(){
        $("#slide").animate({top:0%},1000);
      });
    });

请提出建议。

【问题讨论】:

    标签: jquery position jquery-animate toggle percentage


    【解决方案1】:
    $(document).ready(function(){
          $("#button").toggle(function(){
            $("#slide").animate({top:'-100%'},1000);
          },function(){
            $("#slide").animate({top:'0%'},1000);
          });
        });
    

    添加引号。 (我用的是单引号,但是js不管是'还是")

    【讨论】:

    • @LGVentura 规则:如果 .animate() 或 .css() (我认为前两个可能还有更多)值中还有其他数字,请使用引号。
    猜你喜欢
    • 2012-08-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-16
    • 1970-01-01
    • 1970-01-01
    • 2011-11-01
    • 1970-01-01
    • 2016-10-20
    相关资源
    最近更新 更多