此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Selection:extend() 方法

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

Selection.extend() 方法会将选区的焦点移动到指定的位置。选区的锚点不会发生改变。无论方向如何,最终形成的选区范围都是从锚点到新的焦点。

语法

js
extend(node)
extend(node, offset)

参数

node

要将选区焦点移动到的节点。

offset 可选

node 中将焦点移动到的偏移位置。如果未指定,则使用默认值 0

返回值

无(undefined)。

规范

Specification
Selection API
# dom-selection-extend

浏览器兼容性

参见