jQuery Scroll to bottom of page/iframe
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, body").animate({ scrollTop: $(document).height() }, "slow");
return false;
});
Feel free to change the selector.
scrollTop() returns the number of pixels that are hidden from view from the scrollable area, so giving it:
$(document).height()
will actually overshoot the bottom of the page. For the scroll to actually 'stop' at the bottom of the page, the current height of the browser window needs subtracting. This will allow the use of easing if required, so it becomes:
$('html, body').animate({
scrollTop: $(document).height()-$(window).height()},
1400,
"easeOutQuint"
);
For example:
$('html, body').scrollTop($(document).height());