【发布时间】:2014-10-09 19:22:20
【问题描述】:
我在一个可滚动的 div 标签内有一个表格。当用户向下滚动时,我想使用 jQuery 捕获可见 TR 的 ID。可能会返回数百条记录。如何使用 jQuery 找到顶部可见的表格行 ID?
<div id="mainDiv" style="overflow-y: scroll" class="scrollDiv">
<table id="mainTable" style="table-layout:fixed" height="900px">
<tr id="0">
<td></td>
<td></td>
</tr>
<tr id="1">
<td></td>
<td></td>
</tr>
<tr id="2">
<td></td>
<td></td>
</tr>
</table>
</div>
jQuery
$(".scrollDiv").scroll(function(){
var rowNumber = $(this).closest('tr').children('td:first').text();
//the above returns the top row visible or not. I want the first visible row.
});
【问题讨论】:
标签: jquery ajax asp.net-mvc-3