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
  • 1,968
  • 5
  • 23
  • 47

2 Answers2

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

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

Marinos An
  • 7,669
  • 3
  • 45
  • 80
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
  • 653
  • 4
  • 20