使用jQuery在没有滚动条的情况下检查鼠标滚轮事件 [英] Use jQuery to check mousewheel event without scrollbar
本文介绍了使用jQuery在没有滚动条的情况下检查鼠标滚轮事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在没有滚动条的情况下检查鼠标滚轮的移动?
$(document).mousewheel(function() {clicker.html("a7a");});
解决方案
我强烈推荐你使用这个 jQuery 插件:PLUGIN一个>
没有插件,试试这个例子:EXAMPLE
HTML:
Javascript:
$('#foo').bind('mousewheel', function(e) {如果(e.originalEvent.wheelDelta/120 > 0){警报('向上');} 别的 {警报('向下');}});
div 上没有滚动条但是检测到了滚轮事件.
How to check mousewheel movement without scrollbar?
$(document).mousewheel(function() {
clicker.html("a7a");
});
解决方案 I highly recommend you use this jQuery plugin: PLUGIN
Without a plugin, try this example: EXAMPLE
HTML:
<div id='foo' style='height:300px; width:300px; background-color:red'></div>
Javascript:
$('#foo').bind('mousewheel', function(e) {
if(e.originalEvent.wheelDelta / 120 > 0) {
alert('up');
} else {
alert('down');
}
});
There is no scrollbar on the div but the wheel event is detected.
这篇关于使用jQuery在没有滚动条的情况下检查鼠标滚轮事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文