javascript 在表滚动侦听器上
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17990738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
On table scroll listener
提问by AxelPAL
I'm trying to find out event of scrolling tables. I can get the left param, for example, using:
我试图找出滚动表的事件。我可以得到左边的参数,例如,使用:
$("#scrollTable").offset().left
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).
但是我不能添加它变化的监听器。我想要的一切就是监视表的左滚动参数的变化并将其应用于另一个 DOM 元素(这不是问题)。
HTML example of my table:
我的表格的 HTML 示例:
<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>
采纳答案by NDM
You should bind a listener to the 'scroll'
event, as the docspoint out.
'scroll'
正如文档指出的那样,您应该将侦听器绑定到事件。
$('#target').on('scroll', function() {
// your code
});
obviously, #target
should be a selector for the element that houses the scrollbars, possibly document
or a div you have on overflow
显然,#target
应该是包含滚动条的元素的选择器,可能document
是您拥有的 divoverflow