Get mouse wheel events in jQuery?

前端 未结 14 1406
旧巷少年郎
旧巷少年郎 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:33

    If using mentioned jquery mousewheel plugin, then what about to use the 2nd argument of event handler function - delta:

    $('#my-element').on('mousewheel', function(event, delta) {
        if(delta > 0) {
        console.log('scroll up');
        } 
        else {
        console.log('scroll down');
        }
    });
    

提交回复
热议问题