2015-03-03 113 views
0

看看这个链接:滚动窗口中的元素,该元素具有滚动条。

Scrolling with outer div vertically and inner div horizontally but also hiding the scrollbars

对于选择:

$('pre[class="default prettyprint prettyprinted"]')[4] 

,你会发现一个元素(代码段),其中有滚动条。

是否有可能在js/jquery中执行向下滚动到这些类型的元素?

我知道滚动主窗口中,你可以使用:

$('html, body').animate({scrollTop: $("div[name='appGrid']").offset().top}, 2000); 

或相似的,但如何滚动,其具有滚动条内部元素?

+3

你尝试: $( '预[类= “默认prettyprint prettyprinted”]')[4] .animate({scrollTop的:200},2000); ? – 2015-03-03 09:19:50

+0

哇,这工作。但它不会一直到最后,但它的工作 – batman 2015-03-03 09:21:38

+0

这是因为在上面的代码200,你需要将它设置为$('pre [class =“default prettyprint prettyprinted”]')。height() – 2015-03-03 09:27:14

回答