我正在尝试这样,而不是在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不是一个对象
答案 0 :(得分:11)
要获取touches属性,您可以使用e.originalEvent:
$(document).on('touchstart', function(e){
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
});