我想禁用鼠标滚轮1秒钟.我怎么能这样做?
我有这个功能:
function clickOnMenu(id)
{
switch(id)
{
case 1:
$('.page').css('display','none');
$('#first').click();
rotateImage($('#first'));
$('#menu div').removeClass('active');
$('#first').addClass('active');
break;
case 2:
$('.page').css('display','none');
$('#feature').click();
rotateImage($('#feature'));
$('#feature').addClass('active');
break;
case 3:
$('.page').css('display','none');
$('#download').click();
rotateImage($('#download'));
$('#download').addClass('active');
break;
}
}
Run Code Online (Sandbox Code Playgroud)
这些情况用鼠标滚轮运行.我想在每个案例选中时,鼠标滚轮禁用1秒钟.
我怎么能这样做?
将事件侦听器附加到不执行任何操作的鼠标滚轮.1秒后删除事件监听器.
$('#foo').on('mousewheel', function(e){
e.preventDefault();
return false;
}
setTimeout(function() {
$('#foo').off('mousewheel');
}, 1000);
Run Code Online (Sandbox Code Playgroud)