jquery animate position in percentage

2019-03-19 04:27发布

how do I determine the positions in percentages?

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

Please suggest.

1条回答
成全新的幸福
2楼-- · 2019-03-19 04:52
$(document).ready(function(){
      $("#button").toggle(function(){
        $("#slide").animate({top:'-100%'},1000);
      },function(){
        $("#slide").animate({top:'0%'},1000);
      });
    });

Add quotes. (I used single quotes, but js doesn't care if it is ' or ")

查看更多
登录 后发表回答