0
我在滾動的div標籤內有一個表格。當用戶向下滾動時,我想使用jQuery捕獲可見TR的ID。可能會有幾百條記錄被返回。我怎樣才能找到使用jQuery頂部可見的錶行ID?Div Scroll事件觸發時獲取頂部可視表格行的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.
});
謝謝您的答覆。我期待到現在這樣。 – codeg 2014-10-10 15:14:53
謝謝:)它幫助我的需要。如果任何人需要不可見行的數據,他們可以選擇行的索引而不是可見索引。 – Sathish 2014-10-16 10:22:42