Document: createRange() method


目录

The Document.createRange() method returns a new Range object whose start and end are offset 0 of the Document object on which it was called.

Syntax

createRange()

Parameters

None.

Return value

The created Range object.

Examples

const range = document.createRange();

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

Notes

Once a Range is created, you need to set its boundary points before you can make use of most of its methods.

Specifications

Browser compatibility


版本号 #3
由 壳壳虫 创建于 2026-10-31 03:27:53 UTC
由 cocobook-sync 更新于 2026-11-04 17:33:40 UTC