I have two div
of the same height, but with different contents. And when I do the scroll in one, I wanted the other to go in the same (or at least close to the same) position.
The problem is that their contents do not have the same size , and consequently the size of the scroll bar ends up being different between them. But even with the difference in size I would like to make the second scroll accompany the first one, so that if I roll until the end of the first div
the second should also go to the end, / p>
I do not know if I could make myself clear, but here follows an example of what I intend to do .
(function () {
var target = $("#target")[0]; // <== Getting raw element
$("#source").scroll(function () {
target.scrollTop = this.scrollTop;
target.scrollLeft = this.scrollLeft;
});
})();
I used a solution found in this answer , but the problem is just that the scroll of the second only goes as far as the first one ends, that is, it does not behave properly.
Is there any way to create an "intelligent" scroll-mirror?