The targetTouches
read-only property is 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.
Syntax
var touches = touchEvent.targetTouches;
Return value
touches
- A
TouchList
listing all theTouch
objects for touch points that are still in contact with the touch surface and whosetouchstart
event occurred inside the same targetelement
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 compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
targetTouches
|
Chrome
Full support 22 |
Edge
Full support ≤18 |
Firefox Full support 52 Full support 52 No support 18 — 24 |
IE
No support No |
Opera
Full support Yes |
Safari
No support No |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 6 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
TouchEvent.targetTouches by Mozilla Contributors is licensed under CC-BY-SA 2.5.