在我的页面完成加载后。我希望jQUery能够很好地滚动到页面的底部,快速生成动画,而不是一个快照/颠簸。

我需要像ScrollTo这样的插件吗?或者这是内置到jQuery的某种方式?


当前回答

就像这样:

var $target = $('html,body'); 
$target.animate({scrollTop: $target.height()}, 1000);

其他回答

就像这样:

var $target = $('html,body'); 
$target.animate({scrollTop: $target.height()}, 1000);

js

var el = document.getElementById("el");
el.scrollTop = el.scrollHeight - el.scrollTop;

对于jQuery 3,请更改

$(窗口).load(函数(){ $ (" html,身体”)。animate({scrollTop: $(document).height()}, 1000); })

to:

美元(窗口)。On ("load",函数(e) { $ (" html,身体”)。animate({scrollTop: $(document).height()}, 1000); })

var pixelFromTop = 500;     
$('html, body').animate({ scrollTop: pixelFromTop  }, 1);

所以当页面打开时,它会在1毫秒后自动向下滚动

$('html,body').animate({ scrollTop: 9999 }, 'slow');

就这么简单,9999页高…范围大,所以可以到达底部。