Link side scroll of two elements with jQuery()

This is a nice jQuery trick when you need to scroll the same way on one or several elements at the same time.

$('#divId1').on('scroll', function () {
$('#divId2').scrollLeft($(this).scrollLeft());
});

 

I find it especially usefull for large responsive tables where I make use of some sticky header feature.

I wanted to scroll left and right the same way in the body of the table and the sticky header div.

 

Leave a Reply

Your email address will not be published. Required fields are marked *