Jquery niceScroll set div始终从底部滚动聊天框
我想设置聊天框的div scroll总是从底部开始,如下图所示, 其他解决方案也可以接受Jquery niceScroll set div始终从底部滚动聊天框,jquery,css,nicescroll,Jquery,Css,Nicescroll,我想设置聊天框的div scroll总是从底部开始,如下图所示, 其他解决方案也可以接受 我是这样做的: $('#chat-scroll-container').getNiceScroll(0).doScrollTop($('#chat-content').height()); $('#chat-scroll-container').getNiceScroll(0).doScrollTop($('#chat-content').height(), -1); // -1 is the anima
我是这样做的:
$('#chat-scroll-container').getNiceScroll(0).doScrollTop($('#chat-content').height());
$('#chat-scroll-container').getNiceScroll(0).doScrollTop($('#chat-content').height(), -1); // -1 is the animation duration
让我们假设:
<div id="chat-scroll-container">
<div id="chat-content">
... your messages ...
</div>
</div>
如果不想使用任何动画,请按以下方式执行:
$('#chat-scroll-container').getNiceScroll(0).doScrollTop($('#chat-content').height());
$('#chat-scroll-container').getNiceScroll(0).doScrollTop($('#chat-content').height(), -1); // -1 is the animation duration
请显示迄今为止的尝试($('div2scrollID').scrollTop($('div2scrollID').get(0.scrollHeight)代码>试试这个。或者非常感谢你,这是我的工作。