我正在尝试这样,它不适用于iPhone
$(document).bind('touchstart',function(){
alert('hello');
});
但它的工作方式如下
document.addEventListener('touchstart',function(){
alert('hello');
},false);
如何使用jquery获取touchstart事件?
它的工作
$(document).on('touchstart',function(e){
//e.preventDefault();
var touch = e.touches[0] || e.changedtouches[0];
});
但是获取错误e.touches不是一个对象
解决方法
要获取touches属性,您可以使用e.originalEvent:
$(document).on('touchstart',function(e){
var touch = e.originalEvent.touches[0] || e.originalEvent.changedtouches[0];
});