如何使用 jQuery 将表格的一行滚动到视图 (element.scrollintoView) 中? [英] How do I scroll a row of a table into view (element.scrollintoView) using jQuery?

查看:31
本文介绍了如何使用 jQuery 将表格的一行滚动到视图 (element.scrollintoView) 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jQuery 向表中动态添加行.table 位于 div 内,它具有 overflow:auto 从而导致垂直滚动条.

I'm dynamically adding rows to a table using jQuery. The table is inside a div which has overflow:auto thus causing a vertical scrollbar.

我现在想将我的容器 div 自动滚动到最后一行.tr.scrollintoView() 的 jQuery 版本是什么?

I now want to autoscroll my container div to the last row. What's the jQuery version of tr.scrollintoView()?

推荐答案

var rowpos = $('#table tr:last').position();

$('#container').scrollTop(rowpos.top);

应该可以解决问题!

这篇关于如何使用 jQuery 将表格的一行滚动到视图 (element.scrollintoView) 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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