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
Methods
addRange
- add
Range (range): void Parameters
- range: Range
Returns void
collapse
- collapse(node, offset?): void
Parameters
- node: Node
Optional
offset: number
Returns void
collapseToEnd
collapseToStart
containsNode
- contains
Node (node, allowPartialContainment?): boolean Parameters
- node: Node
Optional
allowPartialContainment: boolean
Returns boolean
deleteFromDocument
empty
extend
- extend(node, offset?): void
Parameters
- node: Node
Optional
offset: number
Returns void
getRangeAt
modify
removeAllRanges
removeRange
- remove
Range (range): void Parameters
- range: Range
Returns void
selectAllChildren
- select
All (node): voidChildren Parameters
- node: Node
Returns void
setBaseAndExtent
setPosition
- set
Position (node, offset?): void Parameters
- node: Node
Optional
offset: number
Returns void
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