---
title: Selection.extend()
slug: Web/API/Selection/extend
translation_of: Web/API/Selection/extend
---
{{ ApiRef("DOM") }}{{SeeCompatTable}}
Selection.extend()
方法移动选中区的焦点到指定的点。选中区的锚点不会移动。选中区将从锚点开始到新的焦点,不管方向。
语法
sel.extend(node, offset)
参数
- node
- 焦点会被移至此节点内。
- offset {{optional_inline}}
- 焦点会被移至
node
内的偏移位置。如果没有指定,使用 0
作为默认值。
规范
Specification |
Status |
Comment |
{{SpecName('HTML Editing', '#dom-selection-extend', 'Selection.extend()')}} |
{{Spec2('HTML Editing')}} |
Initial definition |
{{SpecName('Selection API', '#widl-Selection-extend-void-Node-node-unsigned-long-offset', 'Selection.extend()')}} |
{{Spec2('Selection API')}} |
Current |
浏览器兼容性
{{CompatibilityTable}}
Feature |
Chrome |
Edge |
Firefox (Gecko) |
Internet Explorer |
Opera |
Safari (WebKit) |
Basic support |
{{CompatVersionUnknown()}} |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown()}} |
{{CompatNo}} |
{{CompatVersionUnknown()}} |
{{CompatVersionUnknown()}} |
offset parameter is optional |
{{CompatVersionUnknown}} |
{{CompatUnknown}} |
{{CompatGeckoDesktop(55)}} |
{{CompatNo}} |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown}} |
Feature |
Android |
Edge |
Firefox Mobile (Gecko) |
IE Phone |
Opera Mobile |
Safari Mobile |
Basic support |
{{CompatUnknown}} |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown()}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatVersionUnknown}} |
offset parameter is optional |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatGeckoMobile(55)}} |
{{CompatUnknown}} |
{{CompatUnknown}} |
{{CompatVersionUnknown}} |
相关链接
- {{domxref("Selection")}}, 此方法所属接口。
-