Jquery – 在不可滚动的div上滚动事件
例如: http : //jsbin.com/ofifiy/2/edit#preview
我尝试使用不可滚动的div(绿色)滚动div(红色)。 我的问题是,当我滚动绿色div时,jquery scroll()
不会触发。
HTML
scroll here = scroll the red div
JS
$('#targetWithNoScroll').scroll(function() { $('body').append('No scroll
'); });
您需要将mousewheel事件绑定到该div。 不幸的是,没有本机jQuery鼠标滚轮事件,所以你必须选择一个插件或自己编写。 但我建议你选择其中一个,因为它可以节省你很多时间:
http://brandonaaron.net/code/mousewheel/demos/
http://css-tricks.com/snippets/jquery/horz-scroll-with-mouse-wheel/