此页面由社区从英文翻译而来。了解更多并加入 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 作为默认值。

规范

Specification
Selection API
# dom-selection-extend

浏览器兼容性

参见