跳到可滚动div内的内容 [英] Jump to content inside of a scrollable div

查看:123
本文介绍了跳到可滚动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);

这篇关于跳到可滚动div内的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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