在表上滚动侦听器
问题描述:
我正在尝试找出滚动表的事件. 我可以使用以下方法获取左侧参数:
I'm trying to find out event of scrolling tables. I can get the left param, for example, using:
$("#scrollTable").offset().left
但是我无法添加其更改的侦听器. 我想要做的就是监视表的左滚动参数的变化,并将其应用于另一个DOM元素(这不是问题).
But I can't add the listener of its changing. Everything I want is to monitor the changing of left scroll parameter of table and apply it to another DOM element (that is not a problem).
我的表格的HTML示例:
HTML example of my table:
<div class="scrollTableOuter">
<div id="scrollTableInner" class="scrollTableInner">
<table id="scrollTable" class="persist-area">
<thead>
<tr class="persist-header">
<th style="height: 80px;">Name</th>
<td style="width: 80px;">
</td>
<td style="width: 80px;">
</td>
</tr>
</thead>
<tbody>
<tr>
<th>name</th>
<td style="text-align: center;">
<input class="arrow-change" style="width: 35px; text-align: right;" autocomplete="off" min="0" name="AwardEvent[2][3][value]" id="AwardEvent_2_3_value" type="number" value="1">
</td>
</tr>
</tbody>
</table>
</div></div>
答
You should bind a listener to the 'scroll'
event, as the docs point out.
$('#target').on('scroll', function() {
// your code
});
显然,#target
应该是容纳滚动条的元素的选择器,可能是document
或overflow
obviously, #target
should be a selector for the element that houses the scrollbars, possibly document
or a div you have on overflow