Answer the question
In order to leave comments, you need to log in
How to make div overflow scroll always scroll down?
There is a chat, the messages are inside a div which has overflow: scroll
When I update the chat with ajax, that is, I display new messages from the database and add a new message through append, but it remains at the bottom so that I have to manually scroll down. I tried to scroll down every second along with the chat update
$('#chat-block').scrollTop($('#chat-block')[0].scrollHeight);
Answer the question
In order to leave comments, you need to log in
Track the appearance of a new message and scroll down together with it. But as they wrote in the comment "it's hard to say without layout", but in any case, my advice will direct you in the right direction.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question