You can control two scrollbar with only one, that is, if I move it to the right that they move at the same time ???
You can control two scrollbar with only one, that is, if I move it to the right that they move at the same time ???
<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
height: 250px;
width: 250px;
overflow: auto;
float:left;
}
#myDIV2 {
height: 250px;
width: 250px;
overflow: auto;
}
#content {
height: 800px;
width: 2000px;
background-color: coral;
}
</style>
</head>
<body>
<div id="myDIV" onscroll="myFunction()">
<div id="content">Div 1........................</div>
</div>
<div id="myDIV2" onscroll="myFunction()">
<div id="content">Div 2---------------------------</div>
</div>
<script>
function myFunction() {
var elmnt = document.getElementById("myDIV");
var elmnt2 = document.getElementById("myDIV2");
var x = elmnt.scrollLeft;
var y = elmnt.scrollTop;
elmnt2.scrollLeft = x;
elmnt2.scrollTop = y;
}
</script>
</body>
</html>
With scrollLeft you can get when you have moved to the right and assign it to the div that you also want to move, with scrollTop it is the same but up.
For more information link