문제

Hi I using touchmove event,

this code is not worked for me,

$(".tempClass").on("touchmove",function(){
    alert("touchmove on div");
});

this code is worked for me,

$(document).on("touchmove",function(){
    alert("touchmove on document");
});

my concern why I cant listen for touchmove on div element

I am using phonegap 3.0,android 4.0.4.

Device on I am testing is samsung galaxy tab 10.1

도움이 되었습니까?

해결책

In general, event delegation is used when we don't know when an element will exist in the DOM. It relies on events bubbling up the DOM until they get to the root selection (in your case it's always the document element).

$(document).on('touchmove', '.tempClass', function () {
   // ...
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top