Thursday, December 22nd, 2005

Quick Tip: Scroll to Bottom of a Div

Category: JavaScript

Eric Pascarello has a nice tip on how to scroll to the bottom of a div.

var objDiv = document.getElementById(“divExample”);
objDiv.scrollTop = objDiv.scrollHeight;


Posted by Dion Almaer at 9:22 am

4.2 rating from 48 votes


Comments feed

and if you want to find out stuff like that you can use the mozilla dom inspector.
When you select a node and choose “Javascript Object” on the right hand menu, you get all javascript methods and properties of the node.

Comment by wooyay — December 22, 2005

Does this work cross browser and cross doctype (i.e. standards compliant mode in IE 6 versus quirks mode)? The screen coordinate properties are ‘quirky’ to say the least.

Comment by Brad Neuberg — December 22, 2005

The prototype way…
with ($(“divExample”)) {scrollTop = scrollHeight;}

Comment by kourge — December 22, 2005

Oh my god! Thank you for this, helped tremendously!

Comment by Swizec — December 29, 2005

Leave a comment

You must be logged in to post a comment.