例如,我想捕获一个'scroll'事件,然后暂停侦听,直到执行处理程序。我已经尝试解决这个问题几个小时已经没有成功。
$('body').bind('wheel', function(e){
e.stopPropagation();
if(e.originalEvent.wheelDelta /120 > 0) {
console.log("up");
}
else{
console.log("down");
}
});
编辑:添加了代码示例。
答案 0 :(得分:0)
您可以在body
上切换课程:
$('body').addClass('wheel_disabled'); //removeClass('wheel_disabled');
委派你的活动:
$(document).bind('wheel', 'body:not(.wheel_disabled)', function (e) {
if (e.originalEvent.wheelDelta / 120 > 0) {
console.log("up");
} else {
console.log("down");
}
});