aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/selection/getrangeat/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/selection/getrangeat/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/selection/getrangeat/index.html')
-rw-r--r--files/zh-cn/web/api/selection/getrangeat/index.html65
1 files changed, 65 insertions, 0 deletions
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
+---
+<div>{{APIRef}}</div>
+
+
+<div><strong>概述</strong></div>
+
+
+<p>返回一个包含当前选区内容的区域对象。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><em>range</em> = <em>sel</em>.getRangeAt(<em>index</em>)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><em><code>range</code></em></dt>
+ <dd> 将返回 <a href="/en-US/docs/DOM/range" title="DOM/range">range</a> 对象。</dd>
+ <dt><em><code>index</code></em></dt>
+ <dd>该参数指定需要被处理的子集编号(从零开始计数)。如果该数值被错误的赋予了大于或等于 <a href="/en-US/docs/DOM/Selection/rangeCount" title="DOM/Selection/rangeCount">rangeCount</a> 结果的数字,将会产生错误。</dd>
+</dl>
+
+<h2 id="例子">例子</h2>
+
+<pre class="brush:js">let ranges = [];
+
+sel = window.getSelection();
+
+for(var i = 0; i &lt; sel.rangeCount; i++) {
+ ranges[i] = sel.getRangeAt(i);
+}
+/* 在 ranges 数组的每一个元素都是一个 range 对象,
+<span> * 对象的内容是当前选区中的一个。 */</span></pre>
+
+<h2 id="规范">规范</h2>
+
+<table>
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">注释</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML Editing', '#dom-selection-getrangeat', 'Selection.getRangeAt()')}}</td>
+ <td>{{Spec2('HTML Editing')}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>{{Compat("api.Selection.getRangeAt")}}</p>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li><a href="/en-US/docs/XUL_Tutorial/Tree_Selection" title="XUL_Tutorial/Tree_Selection">Tree Selection</a> (for the <code>getRangeAt()</code> method on the <code>nsITreeSelection</code> interface)</li>
+</ul>