I have this code, to load chat
function getMessages(letter) {
var div = $(\'#messages\');
$.get(\'msg_show.php\', function (data) {
div.html(data);
What you need to do is divide it into two divs. One with overflow set to scroll, and an inner one to hold the text so you can get it's outersize.
textdiv.html("");
$.each(chatMessages, function (i, e) {
textdiv.append("" + e + "
");
});
chatdiv.scrollTop(textdiv.outerHeight());
You can check out a jsfiddle here: http://jsfiddle.net/xj5c3jcn/1/
Obviously you don't want to rebuild the whole text div each time, so take that with a grain of salt - just an example.