<body>
<div id="div1" style="width:620px;height:500px ; float:left;overflow:scroll" onscroll="funcsrcoll1()">
<div style="height:1000px;width:1000px"></div>
</div>
<div id="div2" style="width:620px; height:500px ;float:left;overflow:scroll" onscroll="funcsrcoll2()">
<div style="height:1000px;width:1000px"></div>
</div>
<script>
//控制两个div的滚动条联动,便于页面对比
function funcsrcoll1()
{
document.getElementById("div2").scrollLeft = document.getElementById("div1").scrollLeft;
document.getElementById("div2").scrollTop = document.getElementById("div1").scrollTop;
}
function funcsrcoll2()
{
document.getElementById("div1").scrollLeft = document.getElementById("div2").scrollLeft;
document.getElementById("div1").scrollTop = document.getElementById("div2").scrollTop;
}
</script>
</body>
js控制滚动条联动
于 2015-09-05 18:21:27 首次发布