views:

755

answers:

2

How do I use jquery to scroll right down to the bottom of an iframe or page?

+3  A: 

For example:

$(window).scrollTop($(document).height());
Tatu Ulmanen
I cannot seem to get that to work. Doesn't do anything at all.
Adam
@adam What version of jQuery are you using?
Sonny Boy
I'm using the latest, 1.3.2
Adam
+4  A: 

If you want a nice slow animation scroll, for any anchor with href="#bottom" this will scroll you to the bottom:

$("a[href='#bottom']").click(function() {
  $("html").animate({ scrollTop: $(document).height() }, "slow");
  return false;
});

Feel free to change the selector.

Mark Ursino
This works in Firefox 3.5.7 but not in Chrome 4.0.295.0. The following works in Chrome: $('html, body').animate({scrollTop: $(document).height()}, 'slow');
Tom