Skip to content Skip to sidebar Skip to footer

Auto Scrolldown After Update Div Content

I have DIV with scroll-y and I update content on this DIV via $.get. I don't know how I can make auto scrolldown when new content (on DIV) is longer than old content. CSS #chat-con

Solution 1:

Try setting your div's scrolltop to your div's scrollHeight.

var yourDiv = document.getElementById("chat-conversations");
yourDiv.scrollTop = yourDiv.scrollHeight;

Put this inside $.get's Callback function after appending content to div, this will auto scroll div to the new content.

Update: Sorry bruv. i left a typo.corrected now

Post a Comment for "Auto Scrolldown After Update Div Content"