我有一个shoutbox,我想保持滚动到底部与IM 窗口相同。
我的 html 是
<div id="shoutContainer">
<table id="shoutbox">
<tbody>
<!-- shouts here -->
</tbody>
</table>
</div>
我的CSS
#shoutContainer {
height: 100px; overflow-y: scroll;
}
如果不可能通过 html 和 css。我们可以在原始 javascript 中实现这一点吗?因为我没有使用任何框架
最佳答案
每当添加元素时,请执行以下操作:
document.getElementById('shoutContainer').scrollTop = 10000;
// or some other big number
已编辑
关于javascript - 保持滚动到底部,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2653233/