值
touchList 中的触摸点数量。
示例
此代码示例说明了如何使用 TouchList 接口的 item 方法和 length 属性。
js
const target = document.getElementById("target");
target.addEventListener("touchstart", (ev) => {
// If this touchstart event started on element target,
// set touch to the first item in the targetTouches list;
// otherwise set touch to the first item in the touches list
const touch =
ev.targetTouches.length >= 1
? ev.targetTouches.item(0)
: ev.touches.item(0);
});
规范
| 规范 |
|---|
| 触摸事件 # dom-touchlist-length |
浏览器兼容性
加载中…