在表上滚动侦听器

在表上滚动侦听器

问题描述:

我正在尝试找出滚动表的事件. 我可以使用以下方法获取左侧参数:

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>

您应将侦听器绑定到'scroll'事件,如

You should bind a listener to the 'scroll' event, as the docs point out.

$('#target').on('scroll', function() {
    // your code
});

显然,#target应该是容纳滚动条的元素的选择器,可能是documentoverflow

obviously, #target should be a selector for the element that houses the scrollbars, possibly document or a div you have on overflow