Skip to content

Latest commit

 

History

History
50 lines (33 loc) · 934 Bytes

File metadata and controls

50 lines (33 loc) · 934 Bytes
title short-title slug page-type browser-compat
Range: setEndBefore() method
setEndBefore()
Web/API/Range/setEndBefore
web-api-instance-method
api.Range.setEndBefore

{{ApiRef("DOM")}}

The Range.setEndBefore() method sets the end position of a Range relative to another {{domxref("Node")}}. The parent Node of end of the Range will be the same as that for the referenceNode.

Syntax

setEndBefore(referenceNode)

Parameters

  • referenceNode
    • : The {{domxref("Node")}} to end the Range before.

Return value

None ({{jsxref("undefined")}}).

Examples

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

range.setEndBefore(referenceNode);

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also