简介:
功能简介,js 滚动条自动滚动到最底部
效果展示:
核心代码:
window.scrollTo(0, document.body.scrollHeight);
代码示例:文章来源:https://www.toymoban.com/news/detail-503925.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.js"></script>
</head>
<body>
<div class="panel-body" style="flex-grow: 1; overflow-y: auto; background-color: #343541; color: white;">
</div>
<div style="position: sticky; bottom: 0;">
ceshi
</div>
<script>
setInterval(function() {
$(".panel-body").append("123456<br>" + new Date());
scrollBoxFun();
}, 100)
function scrollBoxFun() {
window.scrollTo(0, document.body.scrollHeight);
}
</script>
</body>
</html>
代码示例2:文章来源地址https://www.toymoban.com/news/detail-503925.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.js"></script>
</head>
<body>
<div class="card" style="height: 100vh;">
<div class="panel-body" style="flex-grow: 1; overflow-y: auto; background-color: #343541; color: white;">
</div>
<div style="position: sticky; bottom: 0;">
ceshi
</div>
</div>
<script>
setInterval(function() {
$(".panel-body").append("123456<br>" + new Date());
scrollBoxFun();
}, 100)
function scrollBoxFun() {
window.scrollTo(0, document.body.scrollHeight);
}
</script>
</body>
</html>
到了这里,关于js 滚动条自动滚动到最底部的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!