AxelPAL
AxelPAL

Reputation: 1027

On table scroll listener

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).

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>

Upvotes: 4

Views: 20190

Answers (1)

NDM
NDM

Reputation: 6830

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

$('#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

Upvotes: 3

Related Questions