A Selection object represents the range of text selected by the user or the current position of the caret. To obtain a Selection object for examination or modification, call Window.getSelection().

interface Selection {
    anchorNode: Node;
    anchorOffset: number;
    focusNode: Node;
    focusOffset: number;
    isCollapsed: boolean;
    rangeCount: number;
    type: string;
    addRange(range): void;
    collapse(node, offset?): void;
    collapseToEnd(): void;
    collapseToStart(): void;
    containsNode(node, allowPartialContainment?): boolean;
    deleteFromDocument(): void;
    empty(): void;
    extend(node, offset?): void;
    getRangeAt(index): Range;
    modify(alter?, direction?, granularity?): void;
    removeAllRanges(): void;
    removeRange(range): void;
    selectAllChildren(node): void;
    setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset): void;
    setPosition(node, offset?): void;
    toString(): string;
}

Properties

anchorNode: Node
anchorOffset: number
focusNode: Node
focusOffset: number
isCollapsed: boolean
rangeCount: number
type: string

Methods

  • Parameters

    Returns void

  • Parameters

    • node: Node
    • Optional offset: number

    Returns void

  • Returns void

  • Returns void

  • Parameters

    • node: Node
    • Optional allowPartialContainment: boolean

    Returns boolean

  • Returns void

  • Returns void

  • Parameters

    • node: Node
    • Optional offset: number

    Returns void

  • Parameters

    • index: number

    Returns Range

  • Parameters

    • Optional alter: string
    • Optional direction: string
    • Optional granularity: string

    Returns void

  • Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • anchorNode: Node
    • anchorOffset: number
    • focusNode: Node
    • focusOffset: number

    Returns void

  • Parameters

    • node: Node
    • Optional offset: number

    Returns void

  • Returns string

Generated using TypeDoc