将触摸事件从Javascript翻译为jQuery

K2x*_*2xL 35 javascript iphone mobile jquery android

我在用

window.addEventListener("touchstart", function(ev){
    console.log(ev.touches); // good
});
Run Code Online (Sandbox Code Playgroud)

我怎样才能将其转换为jQuery?我试过了:

$(window).bind("touchstart",function(ev){
    console.log(ev.touches); // says ev.touches is undefined
}
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Dan*_*ett 46

jQuery'修复'事件以解决浏览器差异.执行此操作时,您始终可以访问"本机"事件event.originalEvent(请参阅此页面上的"特殊属性"子标题).


Sim*_*old 45

$(window).on("touchstart", function(ev) {
    var e = ev.originalEvent;
    console.log(e.touches);
});
Run Code Online (Sandbox Code Playgroud)

我知道很久以前就被问过,但我认为一个具体的例子可能有所帮助.