当我尝试实现以下代码时:
$('.touchelement').bind({'touchstart':function(e){
console.info(e.touches.item(0));
}});它将输出显示为未定义。不仅在touchstart中,而且对于每个其他事件(如(touchmove,touchend) ),它都显示相同的结果。
是否有使用jQuery绑定touchstart事件的替代方法。
发布于 2011-05-31 03:36:37
jQuery对事件对象做了一些处理,以使它们在浏览器中保持一致,但它不知道touches数组,因此不会将其复制到新的事件对象中。因此,您需要通过原始事件对象event.originalEvent来访问它。
$('.touchelement').bind({'touchstart':function(e){
console.info(e.originalEvent.touches[0]);
}});发布于 2011-05-30 15:58:42
它不应该看起来更像这样吗?
$('.touchelement').bind('touchstart', function(e){
console.info(e.touches);
});https://stackoverflow.com/questions/6173382
复制相似问题