我想平滑地向下滚动。我不想为此写一个函数——特别是如果jQuery已经有了一个。


当前回答

$(".scroll-top").on("click", function(e){
   e.preventDefault();
   $("html, body").animate({scrollTop:"0"},600);
});

其他回答

你可以使用.animate() scrollTop属性,就像这样:

$("html, body").animate({ scrollTop: "300px" });

你可以使用jQuery动画滚动页面与特定的持续时间:

$("html, body").animate({scrollTop: "1024px"}, 5000);

其中1024px是滚动偏移量,5000是以毫秒为单位的动画持续时间。

如果你想在页面的末尾向下移动(所以你不需要向下滚动到底部),你可以使用:

$('body').animate({ scrollTop: $(document).height() });

试试scrollTo插件。

但如果你真的想在滚动时添加一些动画,你可以试试我的简单插件(AnimateScroll),它目前支持30多种easing样式