您好我使用touchmove事件,
此代码不适用于我,
$(".tempClass").on("touchmove",function(){
alert("touchmove on div");
});
此代码适用于我,
$(document).on("touchmove",function(){
alert("touchmove on document");
});
我担心为什么我不能在div元素上听touchmove
我正在使用phonegap 3.0,android 4.0.4。
我正在测试的设备是三星galaxy tab 10.1
答案 0 :(得分:2)
通常,当我们不知道DOM中何时存在元素时,会使用事件委托。它依赖于冒泡DOM的事件,直到它们到达根选择(在你的情况下,它总是文档元素)。
$(document).on('touchmove', '.tempClass', function () {
// ...
});