From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../zh-cn/web/api/selection/getrangeat/index.html | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 files/zh-cn/web/api/selection/getrangeat/index.html (limited to 'files/zh-cn/web/api/selection/getrangeat/index.html') diff --git a/files/zh-cn/web/api/selection/getrangeat/index.html b/files/zh-cn/web/api/selection/getrangeat/index.html new file mode 100644 index 0000000000..0271633685 --- /dev/null +++ b/files/zh-cn/web/api/selection/getrangeat/index.html @@ -0,0 +1,65 @@ +--- +title: Selection.getRangeAt() +slug: Web/API/Selection/getRangeAt +translation_of: Web/API/Selection/getRangeAt +--- +
{{APIRef}}
+ + +
概述
+ + +

返回一个包含当前选区内容的区域对象。

+ +

语法

+ +
range = sel.getRangeAt(index)
+
+ +

参数

+ +
+
range
+
 将返回 range 对象。
+
index
+
该参数指定需要被处理的子集编号(从零开始计数)。如果该数值被错误的赋予了大于或等于 rangeCount 结果的数字,将会产生错误。
+
+ +

例子

+ +
let ranges = [];
+
+sel = window.getSelection();
+
+for(var i = 0; i < sel.rangeCount; i++) {
+ ranges[i] = sel.getRangeAt(i);
+}
+/* 在 ranges 数组的每一个元素都是一个 range 对象,
+ * 对象的内容是当前选区中的一个。 */
+ +

规范

+ + + + + + + + + + + + + + +
规范状态注释
{{SpecName('HTML Editing', '#dom-selection-getrangeat', 'Selection.getRangeAt()')}}{{Spec2('HTML Editing')}}Initial definition
+ +

浏览器兼容性

+ +

{{Compat("api.Selection.getRangeAt")}}

+ +

相关链接

+ + -- cgit v1.2.3-54-g00ecf