-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
--- | ||
title: Selection.isCollapsed | ||
title: "Selection: isCollapsed property" | ||
short-title: isCollapsed | ||
slug: Web/API/Selection/isCollapsed | ||
page-type: web-api-instance-property | ||
browser-compat: api.Selection.isCollapsed | ||
--- | ||
|
||
{{ ApiRef() }} | ||
{{ ApiRef("DOM") }} | ||
|
||
### 概述 | ||
**`Selection.isCollapsed`** 只读属性返回一个布尔值,表示当前是否有任何文本被选中。当选定内容的起点和终点位于内容中的同一位置时,没有选定文本。 | ||
|
||
返回一个布尔值用于描述选区的起始点和终止点是否位于一个位置(即是否框选了,译者注)。 | ||
请注意,折叠的选择可能仍有一个(在 Gecko 中为多个){{domxref("Range")}},因此 {{domxref("Selection.rangeCount")}} 可能不为零。在这种情况下,调用 {{domxref("Selection")}} 对象的 {{domxref("Selection.getRangeAt", "getRangeAt()")}} 方法可能会返回折叠的 `Range` 对象。 | ||
|
||
## 值 | ||
|
||
一个布尔值。 | ||
``` | ||
|
||
### 注意 | ||
## 规范 | ||
|
||
即使是一个被折叠了的选区,其 rangeCount 的结果也可能大于 0。sel.getRangeAt(0) 会在选区被折叠的情况下返回一个值。 | ||
{{Specifications}} | ||
|
||
## 浏览器兼容性 | ||
|
||
{{Compat}} | ||
|
||
## 参见 | ||
|
||
- {{domxref("Selection")}} | ||
- {{domxref("Range")}} |