Range.setStartBefore()

Range.setStartBefore() 方法相对另一个 Node来设置一个Range 的开始位置. Range的开始节点(focusNode)的父节点,和  referenceNode的父节点是同一个.

Syntax

range.setStartBefore(referenceNode);

Parameters

referenceNode
一个Range新的开始位置上的Node.

Example

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

range.setStartBefore(referenceNode);

Specifications

Specification Status Comment
DOM
Range.setStartBefore()
Living Standard No change.
Document Object Model (DOM) Level 2 Traversal and Range Specification
Range.setStartBefore()
Obsolete Initial specification.

Browser compatibility

BCD tables only load in the browser

See also