CaretPosition
Baseline 2025Newly available
Since March 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
CaretPosition
接口表示光标位置,即文本插入点的指示器。你可以使用 Document.caretPositionFromPoint()
方法获取 CaretPosition
。
实例属性
该接口不继承任何属性。
CaretPosition.offsetNode
只读 实验性-
返回一个包含光标位置节点的
Node
。 CaretPosition.offset
只读 实验性-
返回一个
long
,表示光标位置在节点中的字符偏移量。
实例方法
CaretPosition.getClientRect
实验性-
返回光标范围的客户端矩形。
规范
Specification |
---|
CSSOM View Module # caret-position |