iphone的safari touchmove活动无法正常工作

我正在使用jquery和touchmove事件,但代码没有在#info中显示任何内容

$('#movieShow').bind('touchmove',function(e){ e.preventDefault(); $('#info').text(e.touches[0].pageX); }); 

尝试使用e.originalEvent.touches

 $('#movieShow').bind('touchmove',function(e){ e.preventDefault(); var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; console.log(touch.pageX); }); 

当我玩触摸事件和jquery时,我遇到了类似的问题: http : //xavi.co/articles/trouble-with-touch-events-jquery

它可能就像一个错误命名的DIV id(’ #info ‘)一样简单,但是如果没有看到一切就无法分辨。

试试这个,看看你是否仍然没有输出:

 $('#movieShow').bind('touchmove',function(e){ e.preventDefault(); console.log(e.touches[0].pageX); }); 

(您需要在MobileSafari中打开调试控制台

UPDATE

因此,从您的评论中您会收到一个错误: 'e.touches' is not an object

在这种情况下尝试这个(不是特定于jQuery):

 document.addEventListener('touchmove', function(e) { e.preventDefault(); }, false); document.getElementById('movieShow').addEventListener('touchmove', function(e){ console.log(e.touches[0].pageX); }, false);