Get mouse wheel events in jQuery?

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

    ​$(document).ready(function(){
        $('#foo').bind('mousewheel', function(e){
            if(e.originalEvent.wheelDelta /120 > 0) {
                console.log('scrolling up !');
            }
            else{
                console.log('scrolling down !');
            }
        });
    });
    

提交回复
热议问题