使用jquery同时滚动2个滚动条 [英] Scroll 2 scrollbars with jquery the same time
问题描述
是否可以使用一个滚动条滚动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屋!