Selection.focusNode

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

Selection.focusNode 是只读的,返回所选内容的结束位置部分所属的节点。

用户可能会从左到右 (按文字方向) 或从右到左 (按文字相反方向) 进行选择。focusNode 就是用户选择时最后停下来所处的元素节点。当你同时按下 shift 键和任何一个方向键来改变选择时,你就能看到:选择的结束位置在移动,但是选择的锚点 - 起始位置不会改变。

语法

node = sel.focusNode

规范

Specification
Selection API
# dom-selection-focusnode

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
focusNode

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参考