jQuery将元素滚动到底部 [英] jQuery scroll an element to the bottom

查看:342
本文介绍了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/

这篇关于jQuery将元素滚动到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆