我可以在 Jquery 中选择单击还是滚动吗?
我有两个事件:
$('#item').click(function...
单击
$(window).scroll(function...
事件滚动页面。但是我想仅在调用单击事件时阻止滚动事件的功能。
当用户手动滚动页面时,我希望滚动事件进行控制。我尝试解除滚动事件的绑定,然后在单击事件完成后再次绑定,但这不起作用。
有什么想法吗?
I have two events:
$('#item').click(function...
and
$(window).scroll(function...
The click event scrolls the page. However I want to prevent the function of the scroll event only when the click event is called.
When the user scrolls the page by hand, then I want the scroll event to take control. I have tried unbinding the scroll event then binding again once the click event completes but that didn't work.
any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我让它以这种方式工作:
http://jsfiddle.net/r9XAN/
这有点奇怪。如果您立即重新绑定滚动事件,它将不起作用。超时为 1 后就可以了。 (至少在 chrome 上)
i got it to work that way:
http://jsfiddle.net/r9XAN/
It's a bit strange. If you rebind the scroll event immediately it won't work. With a timeout of 1 it does. (on chrome at least)