Get mouse wheel events in jQuery?

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

    I was stuck in this issue today and found this code is working fine for me

    $('#content').on('mousewheel', function(event) {
        //console.log(event.deltaX, event.deltaY, event.deltaFactor);
        if(event.deltaY > 0) {
          console.log('scroll up');
        } else {
          console.log('scroll down');
        }
    });
    

提交回复
热议问题