<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<body ontouchstart="showCoordinates(event)" ontouchmove="showCoordinates(event)">
<h1>TouchEvent touches 属性</h1>
<p>请触摸此页面上的任意元素。</p>
<p>触摸的横纵坐标为:<span id="demo"></span></p>
<p><b>注释:</b>此例使用 touches<strong>[0]</strong> 意味着它只会显示一个手指(第一根手指)的坐标。</p>
<p><b>注释:</b>触摸事件仅适用于触摸设备。</p>
<script>
function showCoordinates(event) {
var x = event.touches[0].clientX;
var y = event.touches[0].clientY;
document.getElementById("demo").innerHTML = x + ", " + y;
}
</script>
</body>
</html>