This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

collapsed

Summary

The Range.collapsed read-only property returns a Boolean flag indicating whether the start and end points of the Range are at the same position. It returns true if the start and end boundary points of the Range are the same point in the DOM, false if not.

Property of dom/Rangedom/Range

Syntax

Note: This property is read-only.

var result = range.collapsed;

Return Value

Returns an object of type BooleanBoolean

true - start and end boundary points of the Range are the same point in the DOM

false - start and end boundary points of the Range are NOT the same point in the DOM

Examples

var range = document.createRange();

range.setStart(startNode,startOffset);
range.setEnd(endNode,endOffset);
var isCollapsed = range.collapsed;

Notes

Remarks

A collapsed range has its start and end boundary points set to the same value, rendering it empty.

Syntax

isCollapsed = range.collapsed;

Standards information

Related specifications

DOM
Living Standard

Attributions