--- title: Selection.anchorOffset slug: Web/API/Selection/anchorOffset translation_of: Web/API/Selection/anchorOffset ---
{{ ApiRef("DOM") }}{{SeeCompatTable}}

只读属性,返回选区的锚节点( {{domxref("Selection.anchorNode")}})起点偏移量的数字。返回值从零开始计数,如果选区从锚节点({{domxref("Selection.anchorNode")}})的第一个字符开始,返回值为0。

语法

number = sel.anchorOffset

规范

Specification Status Comment
{{SpecName('HTML Editing', '#dom-selection-anchoroffset', 'Selection.anchorOffset')}} {{Spec2('HTML Editing')}} Initial definition
{{SpecName('Selection API', '#widl-Selection-anchorOffset', 'Selection.anchorOffset')}} {{Spec2('Selection API')}} Current

浏览器兼容性

{{Compat("api.Selection.anchorOffset")}}

相关内容