I would like to get the touchstart and touchend locations if element "#menu" is touched.
I wrote this code, but the event doesn't seem to trigger at all:
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);
});
As far as I know this should work.
Thanks in advance.