Range: collapsed プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.

Range.collapsed は読み取り専用プロパティで、 Range の開始点と終了点が同じ位置にあるかどうかを示す論理型フラグを返します。 Range の開始境界点と終了境界点が DOM 上で同じ位置であれば true を、そうでなければ false を返します。

折りたたまれた Range は空であり(内容を含まない)、 DOM ツリー内の 1 つの点を指定します。範囲を折りたたむには、 Range.collapse() メソッドを参照してください。

論理値。

js
let range = document.createRange();

range.setStart(startNode, startOffset);
range.setEnd(endNode, endOffset);
isCollapsed = range.collapsed;

仕様書

Specification
DOM
# ref-for-dom-range-collapsed①

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
collapsed

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報