Find out how many fingers that touches the surface:
function countTouches(event) {
var x = event.touches.length;
}
Try it Yourself »
The touches property returns an array of Touch objects, one for each finger that is currently touching the surface.
Note: This property is read-only.
event.touches
Return Value: | An Array of Touch objects. |
---|
HTML DOM reference: TouchEvent targetTouches Property
Return the x- and y-coordinates of the touch:
function showCoordinates(event) {
var x = event.touches[0].clientX;
var y = event.touches[0].clientY;
}
Try it Yourself »
event.touches
is a DOM Level 3 (2004) feature.
It is fully supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!