2012-02-22 53 views
8

工作我想這樣和它不是在iphonejQuery的touchstart事件不是iphone

$(document).bind('touchstart',function(){ 
    alert('hello'); 
}); 

工作,但它的工作是這樣

document.addEventListener('touchstart', function(){ 
    alert('hello'); 
}, false); 

如何獲得touchstart事件使用jQuery?

及其與

$(document).on('touchstart', function(e){ 
      //e.preventDefault(); 
      var touch = e.touches[0] || e.changedTouches[0]; 
     }); 

工作,但得到錯誤e.touches不是一個對象

+0

您是否嘗試過: $(document).on('touchstart',function(){ alert('hello'); }); ? – 2012-02-22 07:37:21

+0

查看更新的問題 – coure2011 2012-02-22 07:50:03

回答

11

爲了讓你可以使用e.originalEvent的觸摸特性:

$(document).on('touchstart', function(e){ 
    var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; 
}); 
相關問題