如何使用jQuery将表的一行滚动到视图(element.scrollintoView)中? [英] How do I scroll a row of a table into view (element.scrollintoView) using jQuery?
本文介绍了如何使用jQuery将表的一行滚动到视图(element.scrollintoView)中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用jQuery向表中动态添加行.
table
在具有overflow:auto
的div
内部,因此会导致垂直滚动条.
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屋!
查看全文