jQuery中的鼠标滚轮问题 [英] Problems with mousewheel in jQuery

查看:74
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆