Mobile Safari - in touch event

I would like to have the target when a touch something on the screen of my iPad. But unfortunatly it always returns the currentTarget, never the target.

document.addEventListener('touchstart', onDocumentTouchStart, false);

function onDocumentTouchStart(event) {

  if ( == "div" || == "canvas") {
      // do someting
     // do something else


But is always "HTML". But never the real element I touched, for example an anchor tag or a div.

How do I get the real element I touched?

Thanks a lot.




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, referred to the touched div as intended. You might also check your CSS and/or JS plugins that might be interfering with event bubbling.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.