Mobile Safari - Event.target In Touch Event
I would like to have the target when a touch something on the screen of my iPad. But unfortunately it always returns the currentTarget, never the target. document.addEventListener(
Solution 1:
You might try the "event.touches" array, which will have one entry for each finger currently down, with the "target" value referencing the DOM element touched.
function onDocumentTouchStart(event) {
if (event.touches[0] && event.touches[0].target.tagName.toLowerCase() == "div") {
// do someting
}
}
However, I should note that I was unable to duplicate the original issue; when I tried it, event.target referred to the touched div as intended. You might also check your CSS and/or JS plugins that might be interfering with event bubbling.
Post a Comment for "Mobile Safari - Event.target In Touch Event"