Range: isPointInRange() メソッド

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.isPointInRange() メソッドは、指定されたこの点が Range 内にあるかどうかを示す論理値を返します。このメソッドは ReferenceNode 内の offset にある点(カーソル位置)がこの範囲内にある場合に true を返します。

構文

js
isPointInRange(referenceNode, offset)

引数

referenceNode

Range と比較する Node です。

offset

Range と比較するこの点の Node 内のオフセットです。

返値

論理値です。

js
range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
bool = range.isPointInRange(document.getElementsByTagName("p").item(0), 1);

仕様書

Specification
DOM
# dom-range-ispointinrange

ブラウザーの互換性

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
isPointInRange

Legend

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

Full support
Full support

関連情報