jQuery中的鼠标滚轮问题 [英] Problems with mousewheel in jQuery
问题描述
我的头部有以下代码:
<script type='text/javascript' src='/js/jquery.mousewheel.min.js'></script>
jQuery(function($) {
$('#box').bind('mousewheel', function(event, delta) {
var dir = delta > 0 ? 'Up' : 'Down',
vel = Math.abs(delta);
alert(dir + ' at a velocity of ' + vel);
return false;
});
});
在Firefox 5中,什么都没有发生.在Chrome 13和IE 9中,无论我向哪个方向滚动,都可以以NaN的速度向下移动".
In firefox 5 nothing happens at all. In Chrome 13 and IE 9 I get "Down at a velocity of NaN", no matter at which direction I scroll.
我该如何解决?我要检查的是用户是否向上滚动或向下滚动.
How can I fix this? What I want to do is to check if the user is scorlliing upwards, or if he´s scrolling downwards.
感谢您的帮助!
推荐答案
这意味着delta
是未定义的,这可能意味着您没有包含正确的插件,或在错误的位置包含了它.
It means that delta
is undefined which probably means you didn't include the proper plugin, or included it in the wrong place.
Don't know what you download, I've tried now with this and it's working fine.
如果您删除外部资源,它将无法正常工作.
If you remove the external resource, it won't work as happens in your case.
这篇关于jQuery中的鼠标滚轮问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!