Jquery - 在不可滚动的div上滚动事件

use*_*727 7 jquery scroll

例如: http ://jsbin.com/ofifiy/2/edit#preview

我尝试使用不可滚动的div(绿色)滚动div(红色).我的问题是,当我滚动绿色div时,jquery scroll()不会触发.

HTML

<div id="targetWithNoScroll" style="border:1px solid #0f0;  width:100px; height:100px;">
    scroll here = scroll the red div<br />   
  </div>
Run Code Online (Sandbox Code Playgroud)

JS

$('#targetWithNoScroll').scroll(function() {
  $('body').append('No scroll <br />');
});
Run Code Online (Sandbox Code Playgroud)

Man*_*ore 5

您需要将mousewheel事件绑定到该div.不幸的是,没有本机jQuery鼠标滚轮事件,所以你必须选择一个插件或自己编写.但我建议你选择其中一个,因为它可以节省你很多时间:

http://brandonaaron.net/code/mousewheel/demos/

http://css-tricks.com/snippets/jquery/horz-scroll-with-mouse-wheel/

http://www.ogonek.net/mousewheel/jquery-demo.html