Ale*_*lex 2 jquery events bind gesture
简单的例子:
$('foo').bind('doubletap swiperight', function() {});
Run Code Online (Sandbox Code Playgroud)
所以,我想要真正有效率.也许我想要太高效,但我想要做的是将事件绑定到对象ONCE,然后说"如果swiperight这样做.如果doubletap这样做."
这可能吗??
我在这里先向您的帮助表示感谢!
亚历克斯
您可以使用event.type以下方法从处理函数中确定事件的类型:
$('foo').bind('doubletap swiperight', function(e) {
if (e.type == "doubletap") {
// tap code
}
else if (e.type == "swiperight") {
// swipe code
}
});
Run Code Online (Sandbox Code Playgroud)