I searched for the past 30 minutes, but didn't find a solution.
I want to trigger a touchstart
event on an element.
This fires the touchstart
event:
var e = document.createEvent('MouseEvent');
e.initMouseEvent(touchstart, true, true, window, 1, screenX, screenY, clientX, clientY,
ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);
target.dispatchEvent(e);
Note that the variables are defined by my function
But there's a problem with that. The event
object doesn't have a touches
property. So something like this won't work:
var touch = e.touches[0];
Is there a way to trigger a touchstart
event manually (it should work on Android >= 4.0 and Chrome with touch enabled [DevTools]) ?
Please note, that I do NOT want to use any framework like jQuery. With jQuery it's easy to create a touchevent
on an element ;)