0

I have two div elements side by side with scroll.

If i scroll left div automatically right div also should scroll.(Like beyond compare scroll)

<div id="leftdiv" style="overflow-y: scroll;"> Left Content</div>
<div id="rightdiv" style="overflow-y: scroll;">Right Content</div>
Shakeer Hussain
  • 2,230
  • 7
  • 29
  • 52

2 Answers2

0
$("#leftdiv").on('scroll', function(evt) {
  $("#rightdiv").scrollTop($(this).scrollTop());
})

https://jsfiddle.net/qyvezhvq/10/

Marinos An
  • 9,481
  • 6
  • 63
  • 96
0

see, I hope this is helpful

<script type="text/javascript"> 
$(function(){       
    $( "#leftdiv" ).scroll(function() {         
        if($( "#leftdiv" ).scrollTop() > 0)
        {
            $("#rightdiv").scrollTop($( "#leftdiv" ).scrollTop());  
        }

    }); 
    $( "#rightdiv" ).scroll(function() {            
        if($( "#rightdiv" ).scrollTop() > 0)
        {
            $("#leftdiv").scrollTop($( "#rightdiv" ).scrollTop());  
        }

    });     
});
</script>

Thanks.

dev_ramiz_1707
  • 671
  • 4
  • 20