Join us online - 19th of November
Save your spot
For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.

Interface CaretPosition

The CaretPosition interface represents the caret position, an indicator for the text insertion point. You can get a CaretPosition using the Document.caretPositionFromPoint() method.

MDN Reference

interface CaretPosition {
    offset: number;
    offsetNode: Node;
    getClientRect(): DOMRect | null;
}
Index
offset: number

The offset property of the CaretPosition interface returns an integer representing the offset of the selection in the caret position node.

MDN Reference

offsetNode: Node

The offsetNode property of the CaretPosition interface returns a Node containing the found node at the caret's position.

MDN Reference

  • The getClientRect() method of the CaretPosition interface returns the client rectangle for the caret range.

    MDN Reference

    Returns DOMRect | null

Was this helpful?