I currently have this code written out for a chat style interface and wanted to know how I could go about making it so that the container auto-scrolls to the most recent message. As it currently stands, once the chat container have enough messages to warrant the user to scroll, the newer messages are hidden below the scroll bar. Is there any way to have it so that the most recent message is automatically scrolled to?
Asked
Active
Viewed 203 times
1 Answers
0
if you have jquery you can use the .append() like this
var html='response of chat';
$('.classOfDiv').append(html);
And after use the scrolling function of jquery
$('.classOfDiv').animate({ scrollTop: $('.classOfDiv').height() }, 1000);
Enjoy !

ZelkiN
- 1,721
- 1
- 10
- 6