我正在使用
window.addEventListener("touchstart", function(ev){
console.log(ev.touches); // good
});
如何将其转换为jQuery?我试过了:
$(window).bind("touchstart",function(ev){
console.log(ev.touches); // says ev.touches is undefined
}
有什么想法吗?
答案 0 :(得分:46)
jQuery'修复'事件以解决浏览器差异。执行此操作后,您始终可以使用event.originalEvent
访问“原生”事件(请参阅this page上的特殊属性子标题。)
答案 1 :(得分:45)
$(window).on("touchstart", function(ev) {
var e = ev.originalEvent;
console.log(e.touches);
});
我知道很久以前就被问过,但我认为一个具体的例子可能有所帮助。