Keep two divs sync scroll and example

srcDiv has visible horizontal scrollbar.(style="overflow:auto;")

targetDiv has no scrollbar.(style="overflow:hidden;")

For instance, srcDiv is a tableview without tableheader, targetDiv is a tableheader only. When horizontally scrolling srcDiv, header div should scroll the the same distance accordingly.

function syncDivsScrollPos() {
    $('#srcDiv').on('scroll', function () {
        $('#targetDiv').scrollLeft($(this).scrollLeft());
    });
}

 

posted @ 2015-08-04 13:20  webglcn  阅读(172)  评论(0编辑  收藏  举报