how to scroll down a div with overflow

I was doing a javascript chat application and I got this css/javascript problem of keeping the last entry in the box visible.
How nice is to find that your favourite jS library already thought of that.

Docs:
https://developer.mozilla.org/en/DOM/element.scrollTop
http://docs.jquery.com/CSS/scrollTop


$(document).ready( function (){
// it will scroll down the double of the div's height
// you can change it with any value
$("#scroller").scrollTop( $("#scroller").height() * 2 );
});

Demo:
http://dev.valugi.ro/jquery/scroll-down/


About this entry