2014-02-27 3 views
0
<div id="sampleDiv"></div> 
var elObj = jQuery("#sampleDiv"); 
var elObj = jQuery("#sampleDiv"); 

    function methodToExecute(event) { 
     alert(event.touches[0].pageX); 
     } 

     elObj.bind('touchmove', function() { 
      methodToExecute(event); 
     }); // returns the pageX value but doesn't prevents the default behavior with event.preventDefault() 

     elObj.bind('touchmove', function (event) { 
      methodToExecute(event); 
     }); // Prevents the default behavior with event.preventDefault() but throws error when trying to get pageX value, why ??? 

익명 함수에서 이벤트 인수를 전달하여 올바른 브라우저 동작을 방지하고 터치 장치의 touchmove 이벤트에서 pageX 및 pageY 값을 얻는 올바른 방법은 무엇입니까?익명 함수의 이벤트 인수

답변

0
elObj.bind('touchmove',function(event){ 
    methodToExecute(event); 
}); 

편집 : 나는이

을 게시 한 후 흠, 당신이 질문을 업데이트