item()
方法返回
触摸
object at the specified index in the
TouchList
.
var touchPoint = touchList.item(index);
index
触摸
object to retrieve. The index is a number in the range of 0 to one less than the length of the
TouchList
.
touchPoint
触摸
对象从
TouchList
。返回
null
if the index is not less than the length of the list.
This code example illustrates the use of the
TouchList
接口的
item
方法和
length
特性。
target = document.getElementById("target");
target.addEventListener('touchstart', function(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
var touch;
if (ev.targetTouches.length >= 1)
touch = ev.targetTouches.item(0);
else
touch = ev.touches.item(0);
}, false);
| 规范 | 状态 | 注释 |
|---|---|---|
| Touch Events – Level 2 | 草案 | 非稳定版本。 |
| 触摸事件 | 推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
item
|
Chrome 18 | Edge ≤18 |
Firefox
52
|
IE No | Opera 15 | Safari No | WebView Android Yes | Chrome Android Yes | Firefox Android 6 | Opera Android 14 | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
不支持
TouchList
identifiedTouch()
item()