跳到可滚动div内的内容

问题描述:

如果这个问题的标题有点误导,我不能提出更好的名称。

I apologize if the title of this question is a bit misleading, I could not come up with a better name.

我得到了以下HTML:

I got the following HTML:

<div style="height:200px;overflow-y:scroll;">
  <table>.....</table>
</div>



使用这个设置我有点模仿扩展的< select& / code>控制与定义的@size属性。因此,用户可以选择表中的一行。有一种方法,使表跳起来,使选定的行显示在div的顶部,垂直滚动条滚动到它的位置。我不需要实际的滚动效果。

With this setup I'm somewhat mimicking the expanded <select> control with @size attribute defined. So, that a user could select a row in the table. Is there a way, to make the table "jump up", so that the selected row appears to be at the top of the div and the vertical scrollbar scrolled to its position. I don't need the actual scrolling effect. The table should change it's position right away on row click.

我觉得这不是一个很好的解释,我很难找到正确的单词。请让我知道我是否应该澄清什么。

I feel like this isn't a very good explanation, I'm struggling to find the right words. Let me know if I should clarify anything, please.

谢谢。

这可能有用:

$("#scrollableDiv").animate({
  scrollTop: 200 // scrolls to the bottom
}, 1000);