Range: selectNode() method

The Range.selectNode() method sets the Range to contain the Node and its contents. The parent Node of the start and end of the Range will be the same as the parent of the referenceNode.

Syntax

js
selectNode(referenceNode)

Parameters

referenceNode

The Node to select within a Range.

Return value

None (undefined).

Examples

js
let range = document.createRange();
let referenceNode = document.getElementsByTagName("div").item(0);

range.selectNode(referenceNode);

Specifications

Specification
DOM Standard
# dom-range-selectnode

Browser compatibility

BCD tables only load in the browser

See also