一、 (准确性更高)
//将滚动条定位在内容最底部
var getreviewHeight = $('.reviewRuleList').prop("scrollHeight"); //等同 $('.reviewRuleList')[0].scrollHeight
$('.reviewRuleList').animate({scrollTop: getreviewHeight}, 50);//使滚动条显示在底部
二、
$('.reviewRuleList').animate({scrollTop: $(document).height()}, 50);//使滚动条显示在底部
整个文档滚动条到底部:
1. 使用jQuery的animate()方法:
$('html, body').animate({scrollTop:$(document).height()}, 'slow');
2. 使用jQuery的scrollTop()方法:
$('html, body').scrollTop($(document).height());
3. 使用window.scrollTo()方法:
window.scrollTo(0,document.body.scrollHeight);
这篇博客介绍了如何利用jQuery的animate()、scrollTop()和window.scrollTo()方法将页面滚动条定位到内容底部,适用于前端开发中需要自动滚动的场景。示例代码详细展示了不同方法的用法。
438

被折叠的 条评论
为什么被折叠?



