我有一个可滚动的 <div>
(overflow: auto;
),我想检测在该 div 内拖动滚动条的事件。我当前的代码如下:
var scrollableDiv = $('.scrollablediv');
$(document).on('DOMMouseScroll mousewheel touchmove scroll', scrollableDiv, function(e){
// do something
});
但它只在使用鼠标滚轮时触发。如果我拖动浏览器生成的
的滚动条,当内容溢出时,事件不会被触发。我需要添加什么才能使其正常工作?
scrollableDiv
是什么?选择器、DOM元素、jQuery对象? - hindmost.on()
不期望将jquery对象作为参数。为什么不立即将监听器绑定到scrollableDiv
上:scrollableDiv.on(..)
? - hindmoston('scroll')
](http://jsfiddle.net/davidThomas/cqpmL96o/)对我来说似乎有效,并且可以对拖动滚动条做出反应。 - David Thomas