2012-02-22 3 views
8

에서 작동하지 않는 나는이 같은 노력과 아이폰JQuery와 touchstart 이벤트는 아이폰

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

에서 작동하지 않습니다하지만 어떻게 jQuery로 작업 touchstart 이벤트를 얻을이

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

처럼하고 있어요?

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

작업을하지만 오류 e.touches을 얻는 것은 당신이 e.originalEvent를 사용할 수있는 터치 속성을 얻으려면 객체

+0

당신이 해봤를 : $ (문서) .on ('touchstart', function() { alert ('hello'); }); ? –

+0

업데이트 된 질문보기 – coure2011

답변

11

되지 않습니다 :

$(document).on('touchstart', function(e){ 
    var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; 
}); 
관련 문제