[英]jquery - scroll page to bottom
I simply want to scroll a page to the bottom我只想将页面滚动到底部
seems - it is a deep secret似乎 - 这是一个深奥的秘密
$(window).on('load', function(){
let y = $('body').height();
console.log(y); // 2285
$('document').scrollTop(y);
});
also tried:也试过:
$('document').scrollTop(y + 'px');
$('body').scrollTop(y);
$('body').scrollTop(y + 'px');
also tried some code from here - without success也从这里尝试了一些代码 - 但没有成功
please help请帮忙
Here is the alternative way.这是另一种方法。 It works for me.
这个对我有用。
<script>
jQuery(document).ready(function () {
jQuery("button").click(function () {
jQuery("html, body").animate(
{
scrollTop: jQuery("html, body").get(0).scrollHeight,
},
1000
);
});
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.