Get mouse wheel events in jQuery?

前端 未结 14 1485
旧巷少年郎
旧巷少年郎 2020-11-22 13:26

Is there a way to get the mouse wheel events (not talking about scroll events) in jQuery?

14条回答
  •  时光说笑
    2020-11-22 13:38

    I got same problem recently where $(window).mousewheel was returning undefined

    What I did was $(window).on('mousewheel', function() {});

    Further to process it I am using:

    function (event) {
        var direction = null,
            key;
    
        if (event.type === 'mousewheel') {
            if (yourFunctionForGetMouseWheelDirection(event) > 0) {
                direction = 'up';
            } else {
                direction = 'down';
            }
        }
    }
    

提交回复
热议问题