Selection.focusOffset

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.focusOffset 返回选区终点(鼠标松开瞬间所记录的那个点)在焦点(Selection.focusNode)中的偏移量。返回值从零开始计数,如果选区(Selection)在焦点(Selection.focusNode)的第一个字符前结束,返回值为 0。

语法

offset = sel.focusOffset

规范

Specification
Selection API
# dom-selection-focusoffset

浏览器兼容性

BCD tables only load in the browser

相关链接