Get mouse wheel events in jQuery?

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

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

14条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 13:45

    This is working in each IE, Firefox and Chrome's latest versions.

    $(document).ready(function(){
            $('#whole').bind('DOMMouseScroll mousewheel', function(e){
                if(e.originalEvent.wheelDelta > 0 || e.originalEvent.detail < 0) {
                    alert("up");
                }
                else{
                    alert("down");
                }
            });
        });
    

提交回复
热议问题