Interface Selection
interface Selection {
anchorNode: Node;
anchorOffset: number;
direction: string;
focusNode: Node;
focusOffset: number;
isCollapsed: boolean;
rangeCount: number;
type: string;
addRange(range: Range): void;
collapse(node: Node, offset?: number): void;
collapseToEnd(): void;
collapseToStart(): void;
containsNode(node: Node, allowPartialContainment?: boolean): boolean;
deleteFromDocument(): void;
empty(): void;
extend(node: Node, offset?: number): void;
getRangeAt(index: number): Range;
modify(alter?: string, direction?: string, granularity?: string): void;
removeAllRanges(): void;
removeRange(range: Range): void;
selectAllChildren(node: Node): void;
setBaseAndExtent(
anchorNode: Node,
anchorOffset: number,
focusNode: Node,
focusOffset: number,
): void;
setPosition(node: Node, offset?: number): void;
toString(): string;
}
anchorNode: Node;
anchorOffset: number;
direction: string;
focusNode: Node;
focusOffset: number;
isCollapsed: boolean;
rangeCount: number;
type: string;
addRange(range: Range): void;
collapse(node: Node, offset?: number): void;
collapseToEnd(): void;
collapseToStart(): void;
containsNode(node: Node, allowPartialContainment?: boolean): boolean;
deleteFromDocument(): void;
empty(): void;
extend(node: Node, offset?: number): void;
getRangeAt(index: number): Range;
modify(alter?: string, direction?: string, granularity?: string): void;
removeAllRanges(): void;
removeRange(range: Range): void;
selectAllChildren(node: Node): void;
setBaseAndExtent(
anchorNode: Node,
anchorOffset: number,
focusNode: Node,
focusOffset: number,
): void;
setPosition(node: Node, offset?: number): void;
toString(): string;
}
Index
Properties
Readonly
anchorNode
Readonly
anchorOffset
anchorOffset: number
Readonly
direction
direction: string
Readonly
focusNode
Readonly
focusOffset
focusOffset: number
Readonly
isCollapsed
isCollapsed: boolean
Readonly
rangeCount
rangeCount: number
Readonly
type
type: string
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().
MDN Reference