jQuery将元素滚动到底部
问题描述:
我在网上可以找到的所有内容都告诉我如何将页面滚动到底部或元素.
All I can find on the web tells me how to scroll the page to the bottom or to an element.
如何使用jQuery将具有"overflow:auto"样式的特定div滚动到底部?
How is it possible to scroll a specific div which has the style "overflow:auto" to the bottom using jQuery?
答
是:
$("#container").scrollTop($("#elementToScrollTo").position().top);
如果您想顺利进行:
$("#container").animate({
scrollTop: $("#elementToScrollTo").position().top
}, 1000);
在这里,摆弄一个小提琴: http://jsfiddle.net/adrianonantua/nxHE8/
Here, have a fiddle: http://jsfiddle.net/adrianonantua/nxHE8/