item() 方法返回 触摸 object at the specified index in the TouchList .

句法

var touchPoint = touchList.item(index);
					

参数

index
The index of the 触摸 object to retrieve. The index is a number in the range of 0 to one less than the length of the TouchList .

返回值

touchPoint
The requested 触摸 对象从 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 草案 非稳定版本。
触摸事件 推荐 初始定义。

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
item Chrome 18 Edge ≤18 Firefox 52
52
不支持 18 — 24
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

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改:
  1. 触摸事件
  2. TouchList
  3. 特性
    1. length
  4. 方法
    1. identifiedTouch()
    2. item()
  5. Related pages for Touch Events
    1. 触摸
    2. TouchEvent