W3cubDocs

/DOM

TouchEvent.targetTouches

A TouchList listing all the Touch objects for touch points that are still in contact with the touch surface and whose touchstart event occurred inside the same target element as the current target element.

This property is Read only .

Syntax

var touches = touchEvent.targetTouches;

Return value

touches
A TouchList listing all the Touch objects for touch points that are still in contact with the touch surface and whose touchstart event occurred inside the same target element as the current target element.

Example

This example illustrates the TouchEvent object's TouchEvent.targetTouches property. The TouchEvent.targetTouches property is a TouchList object that includes those TPs that are currently touching the surface and started on the element that is the target of the current event. As such, the targetTouches list is a strict subset of the touches list.

In following code snippet, the function compares the length of the touches list to the the length of the targetTouches list and returns true if the lengths are the same and returns false otherwise.

function touches_in_target(ev) {
  // Return true if all of the touches are within the target element;
  // otherwise return false.
  return (ev.touches.length == ev.targetTouches.length ? true : false);
}

Specifications

Specification Status Comment
Touch Events – Level 2 Draft Non-stable version.
Touch Events Recommendation Initial definition.

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 22 Yes 52
52
18 — 24
No Yes No
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support Yes Yes ? 6 Yes Yes ?

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/targetTouches