TouchList: length プロパティ
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
length
は読み取り専用のプロパティで、指定された TouchList
の項目(タッチポイント)の数を示します。
値
touchList
のタッチポイントの数です。
例
このコード例では、TouchList
インターフェイスの item
メソッドと length
プロパティの使い方を示しています。
js
const target = document.getElementById("target");
target.addEventListener(
"touchstart",
(ev) => {
// この touchstart イベントが対象要素で始まった場合、touch を
// targetTouches リストの最初の項目に設定します。そうでない
// 場合は、touch リストの最初の項目に touch を設定します。
const touch =
ev.targetTouches.length >= 1
? ev.targetTouches.item(0)
: ev.touches.item(0);
},
false,
);
仕様書
Specification |
---|
Touch Events # dom-touchlist-length |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
length |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- No support
- No support
- Has more compatibility info.
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.