使用jquery同时滚动2个滚动条 [英] Scroll 2 scrollbars with jquery the same time

查看:94
本文介绍了使用jquery同时滚动2个滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用一个滚动条滚动2个滚动条?

解决方案

$ c> scrollTop 的一个元素的属性到另一个的 scrollTop ,使用绑定到 code>

 $('。linked')。scroll(function(){
$('。linked')。scrollTop($(this).scrollTop());
})

使用该函数,所有具有链接当您使用其中一个的滚动条时滚动。 (我假设垂直滚动,如果你想水平,做同样,但 scrollLeft



=http://jsfiddle.net/g8Krz/510/> http://jsfiddle.net/g8Krz/510/ 上面的工作示例。


Is it possible to scroll 2 scrollbars with one scrollbar?

解决方案

All you need to do it tie the scrollTop property of one element to the scrollTop of the other, using a function tied to the scroll event.

Something along the lines of:

$('.linked').scroll(function(){
    $('.linked').scrollTop($(this).scrollTop());    
})

With that function, all elements with a class of linked will scroll whenever you use the scrollbars of one of them. (I assumed vertical scrolling, if you wanted horizontal, do the same but with scrollLeft)

See http://jsfiddle.net/g8Krz/510/ for a working example of the above.

这篇关于使用jquery同时滚动2个滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆