由于Touchstart / touchend在大多数桌面浏览器中尚
不支持。如何创建与mousedown事件(所有浏览器都
支持)相同的touchstart事件。
我想要这样的东西
$('obj').bind('touchstart',function(e){
});
将被翻译成
$('obj').bind('mousedown',function(e){
})
您可以一次绑定两个
$('obj').bind('touchstart mousedown',function(e){
});
如果你想要mousedown事件自动触发touchstart事件(所以你只需要绑定touchstart)使用…
$(document).bind('mousedown',function(event) {
$(event.target).trigger('touchstart');
});
请注意,这意味着mousedown事件必须传播到文档,才能触发自定义touchstart事件。这可能会有意想不到的副作用。