在jquery mousewheel事件中取消绑定事件

时间:2017-07-11 07:56:38

标签: jquery

Using the hscroll as in the jsfiddle 在div水平滚动结束后寻找取消绑定事件

 jQuery(function ($) {
    $.fn.hScroll = function (amount) {
        amount = amount || 120;
        $(this).bind("DOMMouseScroll mousewheel", function (event) {
            var oEvent = event.originalEvent, 
                direction = oEvent.detail ? oEvent.detail * -amount : oEvent.wheelDelta, 
                position = $(this).scrollLeft();
            position += direction > 0 ? -amount : amount;
            $(this).scrollLeft(position);
            event.preventDefault();
        })
    };
});

1 个答案:

答案 0 :(得分:0)

检查reference并根据您的jquery版本选择offunbind

你可以使用的东西

$(this).off("DOMMouseScroll");

$(this).off("mousewheel");
相关问题