Reputation: 751
I'm working on a chat app, using jquery and bootstrap. I append new chat messages to a div and want to scroll the div so that the most recent message (at the bottom) is always showing. But the scrollTop() function doesn't seem to work. Here is a dummy version of the app: http://www.bootply.com/fE8QRrtNkR The log-container div is the outer container. Within it, the display-padder div is used to pad the log-container so that when we add messages, they are displayed at the bottom first. Messages are appended to the log div. scrollTop() is called in the appendLog() function.
Upvotes: 0
Views: 219
Reputation: 58
I dont think scrollTop("100%") works. You should replace
$('#log').scrollTop("100%");
in appendLog function with
$('#log-body').scrollTop($("#log").height());
Upvotes: 1