扫码关注官方订阅号
兼容谷歌,火狐,IE
业精于勤,荒于嬉;行成于思,毁于随。
window.onload=function() { var oBox=document.getElementById('box'); wheel(oBox,function(down){ alert(down); }); } function wheel(obj,wheelFn) { window.navigator.userAgent.indexOf('Firefox')!=-1 ? obj.addEventListener('DOMMouseScroll',fn,false) : addEvent(obj,'mousewheel',fn); function fn(ev) { var oEvent=ev||event; var down=oEvent.wheelDelta ? down=oEvent.wheelDelta<0 : down=oEvent.detail>0; ev.preventDefault&&ev.preventDefault(); wheelFn&&wheelFn(down); return false; } } function addEvent(obj,sEv,fn) { obj.addEventListener ? obj.addEventListener(sEv,fn,false) : obj.attachEvent('on'+sEv,fn); }
jquery-mousewheel
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
jquery-mousewheel