在表上滚动侦听器 [英] On table scroll listener

查看:97
本文介绍了在表上滚动侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

这篇关于在表上滚动侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆