Scroll to bottom of div?
Here's what I use on my site:
var objDiv = document.getElementById("your_div");objDiv.scrollTop = objDiv.scrollHeight;
This is much easier if you're using jQuery scrollTop:
$("#mydiv").scrollTop($("#mydiv")[0].scrollHeight);
You can try the code below:
function scrollToBottom (id) { var div = document.getElementById(id); div.scrollTop = div.scrollHeight - div.clientHeight;}
To perform a smooth scroll with JQuery:
function scrollSmoothToBottom (id) { var div = document.getElementById(id); $('#' + id).animate({ scrollTop: div.scrollHeight - div.clientHeight }, 500);}
See the example on JSFiddle
Here's why this works:
Ref: scrollTop, scrollHeight, clientHeight