Reputation: 247
I want my div to automatically stay at the bottom when a paragraph is added, how would I do this? This is my code:
Upvotes: 0
Views: 581
Reputation: 4067
Here you go: http://jsfiddle.net/tMnvJ/
Just put that JavaScript code in a function and call it by whatever process adds your content. Something like this...
function addParagraph()
{
//do you add paragraph stuff...
//then call this line to scroll to the bottom of your div
document.getElementById('myDiv').scrollTop = document.getElementById('myDiv').scrollHeight;
}
Hope that helps.
Upvotes: 2