Problems with mousewheel in jQuery

后端 未结 4 1567
北海茫月
北海茫月 2021-01-13 18:29

I have the following code in the head-section:



jQuery(function($         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-13 18:56

    Here is a cross-browser solution:

    var onMouseWheel = function(e) {
        e = e.originalEvent;
        var delta = e.wheelDelta>0||e.detail<0?1:-1;
        alert(delta);
    }
    $("body").bind("mousewheel DOMMouseScroll", onMouseWheel);
    

提交回复
热议问题