G
G
gomer17262018-02-09 17:02:30
css
gomer1726, 2018-02-09 17:02:30

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);

But it's not like that

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Kotosin, 2018-02-09
@av_kotosin

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 question

Ask a Question

731 491 924 answers to any question