【发布时间】:2015-02-10 13:01:52
【问题描述】:
如果元素“#menu”被触摸,我想获取 touchstart 和 touchend 位置。
我写了这段代码,但事件似乎根本没有触发:
var lastLoc = 0;
$(document).on('touchstart', '#menu', function(e) {
lastLoc = e.originalEvent.touches[0].pageX;
});
$(document).on('touchend', '#menu', function(e) {
var newLoc = e.originalEvent.touches[0].pageX;
alert("lastLoc = "+lastLoc+", newLoc = "+newLoc);
});
据我所知,这应该可行。
提前致谢。
【问题讨论】:
标签: javascript html touch