-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
45 lines (31 loc) · 1019 Bytes
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
---
title: "Range: collapsed property"
short-title: collapsed
slug: Web/API/Range/collapsed
page-type: web-api-instance-property
browser-compat: api.Range.collapsed
---
{{ APIRef("DOM") }}
The **`Range.collapsed`** read-only property returns a
boolean flag indicating whether the start and end points of the
{{domxref("Range")}} are at the same position. It returns `true` if the start
and end boundary points of the {{domxref("Range")}} are the same point in the DOM,
`false` if not.
A collapsed {{domxref("Range")}} is empty (containing no content), and specifies a
single point in a DOM tree. To collapse a range, see the {{domxref("Range.collapse()")}}
method.
## Value
A boolean.
## Examples
```js
let range = document.createRange();
range.setStart(startNode, startOffset);
range.setEnd(endNode, endOffset);
isCollapsed = range.collapsed;
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [The DOM interfaces index](/en-US/docs/Web/API/Document_Object_Model)