jQuery滚动到页面底部/ iframe
如何使用jquery向下滚动到iframe或页面的底部?
如果你想要一个很好的慢animation滚动,对于任何具有href="#bottom"锚点,这将滚动到底部: 
 $("a[href='#bottom']").click(function() { $("html, body").animate({ scrollTop: $(document).height() }, "slow"); return false; }); 
随意更改select器。
编辑:请看下面的答案汤姆·贝茨为一个潜在的更好的答案。
scrollTop()返回从可滚动区域的视图中隐藏的像素的数量,所以给它:
 $(document).height() 
实际上会超过页面的底部。 对于页面底部的滚动实际“停止”,浏览器窗口的当前高度需要减去。 这将允许使用宽松,如果需要,所以它变成:
 $('html, body').animate({ scrollTop: $(document).height()-$(window).height()}, 1400, "easeOutQuint" ); 
例如:
 $(window).scrollTop($(document).height()); 
在这个线程没有针对我的具体需求(在一个特定的元素内滚动,在我的情况下是一个textarea)之后,我发现了这个问题,这对其他人阅读这个讨论会有帮助:
在planetcloud上的替代品
 由于我已经有了我的jQuery对象的caching版本(下面的代码中的myPanel是jQuery对象),我添加到我的事件处理程序的代码是这样的: 
 myPanel.scrollTop(myPanel[0].scrollHeight - myPanel.height()); 
(谢谢Ben)
 一个简单的函数,跳转(即时滚动)到整个页面的底部。 它使用内置的.scrollTop() 。 我还没有试图去适应这个单独的页面元素。 
 function jumpToPageBottom() { $('html, body').scrollTop( $(document).height() - $(window).height() ); } 
这个为我工作:
 var elem = $('#box'); if (elem[0].scrollHeight - elem.scrollTop() == elem.outerHeight()) { // We're at the bottom. } 
 如果你不关心animation,那么你不需要获得元素的高度。 至less在我尝试过的所有浏览器中,如果您给scrollTop一个比最大值大的数字,它就会滚动到底部。 所以给它可能的最大的数字: 
 $(myScrollingElement).scrollTop(Number.MAX_SAFE_INTEGER); 
 如果你想滚动页面,而不是滚动条的某个元素,只需使myScrollingElement等于“body,html”。 
由于我需要在几个地方做这个,所以我写了一个快速而肮脏的jQuery函数来使它更方便,就像这样:
 (function($) { $.fn.scrollToBottom = function() { return this.each(function (i, element) { $(element).scrollTop(Number.MAX_SAFE_INTEGER); }); }; }(jQuery)); 
所以我可以做到这一点,当我追加buncho的东西:
 $(myScrollingElement).append(lotsOfHtml).scrollToBottom(); 
在以前的答案中提到的脚本,如:
 $("body, html").animate({ scrollTop: $(document).height() }, 400) 
要么
 $(window).scrollTop($(document).height()); 
  将无法在Chrome中 工作 ,并将在Safari 浏览器中跳跃,以防 CSS中的 html标签overflow: auto; 财产集。 花了我近一个小时才弄明白。