jquery的click事件可以模拟鼠标滚轮的上下吗?
jquery的click事件可以模拟鼠标滚轮的上下吗?我尝试访问某些功能链接:单击向上箭头,模拟鼠标滚轮向上。单击向下箭头,模拟鼠标滚轮向下。
<a id="up">up</a>
<a id="down">down</a>
$('#up').click(){
$('#left').bind('mousewheel',up); //scroll div#left to top
});
$('#down').click(){
$('#left').bind('mousewheel',down); //scroll div#left to bottom
});
Can jquery click event simulate mousewheel up and down? I tried to reach some function link: click up arrow, simulate mousewheel up. click down arrow, simulate mousewheel down.
<a id="up">up</a>
<a id="down">down</a>
$('#up').click(){
$('#left').bind('mousewheel',up); //scroll div#left to top
});
$('#down').click(){
$('#left').bind('mousewheel',down); //scroll div#left to bottom
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一种有趣的做法。
小提琴:http://jsfiddle.net/C9ze6/
This is an interesting way of doing it.
Fiddle: http://jsfiddle.net/C9ze6/
.bind
不模拟事件 - 使用.trigger
和/或.triggerHandler
来模拟事件。另外,请注意,普通 jQuery 不支持鼠标滚轮事件 - 您需要一个插件。请参阅http://plugins.jquery.com/plugin-tags/mousewheel。但也许.scroll
对你来说已经足够了。.bind
does not simulate an event - use.trigger
and/or.triggerHandler
for that. Also, note that plain jQuery does not support mousewheel events - you need a plugin for that. See http://plugins.jquery.com/plugin-tags/mousewheel. But maybe.scroll
will be good enough for you.