我正在尝试实现类似 here 的效果.每次滚动滚轮时,我都想执行一个操作,无论用户尝试滚动多少次。我将如何计算用户尝试滚动的次数?我一直在玩 $(window).on('scroll'...
。谢谢
最佳答案
你的意思是这样的:
(function() {
var scroll = 0;
$(document).on('mousewheel DOMMouseScroll', function(event) {
scroll++;
console.log(event);
});
$('#click').on('click', function() {
alert(scroll);
});
})();
<button id="click">Show me</button>
(你显然可以用自己的代码代替 scroll++;
)
关于javascript - 检测鼠标滚轮滚动的次数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18751793/