Question

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

Was it helpful?

Solution

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 () {
   // ...
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top