A fragment of a document that can contain nodes and parts of text nodes.

MDN Reference

interface Range {
    collapsed: boolean;
    commonAncestorContainer: Node;
    END_TO_END: 2;
    END_TO_START: 3;
    endContainer: Node;
    endOffset: number;
    START_TO_END: 1;
    START_TO_START: 0;
    startContainer: Node;
    startOffset: number;
    cloneContents(): DocumentFragment;
    cloneRange(): Range;
    collapse(toStart?: boolean): void;
    compareBoundaryPoints(how: number, sourceRange: Range): number;
    comparePoint(node: Node, offset: number): number;
    createContextualFragment(string: string): DocumentFragment;
    deleteContents(): void;
    detach(): void;
    extractContents(): DocumentFragment;
    getBoundingClientRect(): DOMRect;
    getClientRects(): DOMRectList;
    insertNode(node: Node): void;
    intersectsNode(node: Node): boolean;
    isPointInRange(node: Node, offset: number): boolean;
    selectNode(node: Node): void;
    selectNodeContents(node: Node): void;
    setEnd(node: Node, offset: number): void;
    setEndAfter(node: Node): void;
    setEndBefore(node: Node): void;
    setStart(node: Node, offset: number): void;
    setStartAfter(node: Node): void;
    setStartBefore(node: Node): void;
    surroundContents(newParent: Node): void;
    toString(): string;
}

Hierarchy (view full)

Properties

collapsed: boolean

Returns true if range is collapsed, and false otherwise.

MDN Reference

commonAncestorContainer: Node

Returns the node, furthest away from the document, that is an ancestor of both range's start node and end node.

MDN Reference

END_TO_END
END_TO_START
endContainer: Node

Returns range's end node.

MDN Reference

endOffset: number

Returns range's end offset.

MDN Reference

START_TO_END
START_TO_START
startContainer: Node

Returns range's start node.

MDN Reference

startOffset: number

Returns range's start offset.

MDN Reference

Methods

  • Parameters

    • OptionaltoStart: boolean

    Returns void

  • Parameters

    • how: number
    • sourceRange: Range

    Returns number

  • Returns −1 if the point is before the range, 0 if the point is in the range, and 1 if the point is after the range.

    MDN Reference

    Parameters

    • node: Node
    • offset: number

    Returns number

  • Returns void

  • Returns void

  • Returns DOMRectList

  • Parameters

    Returns void

  • Returns whether range intersects node.

    MDN Reference

    Parameters

    Returns boolean

  • Parameters

    • node: Node
    • offset: number

    Returns boolean

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • node: Node
    • offset: number

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • node: Node
    • offset: number

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Returns a string representation of an object.

    Returns string