setStart
Summary
Sets the starting point of a range
Syntax
var result = range.setStart(/* see parameter list */);
Parameters
startNode
- Data-type
- DOM Node
Node in the document hierarchy.
startOffset
- Data-type
- Number
Specifies the offset value for the starting point.
Return Value
Returns an object of type NumberNumber
Type: HRESULT
This method can return one of these values.
Return code | Description |
---|---|
S_OK | The operation completed successfully. |
InvalidStateError | detach has been invoked on the object. |
W3Exception_DOM_INDEX_SIZE_ERR | offset is negative or greater than the number of child units in refNode. |
Examples
var range = document.createRange(); var startNode = document.getElementsByTagName("p").item(2); var startOffset = 0; range.setStart(startNode,startOffset);
Notes
If the startNode is a Node of type Text, Comment, or CDATASection, then startOffset is the number of characters from the start of startNode. For other Node types, startOffset is the number of child nodes between the start of the startNode.
Syntax
range.setStart(startNode, startOffset);
Standards information
Related specifications
- DOM
- Living Standard
Attributions
Mozilla Developer Network : [Range.setStart Article]
Microsoft Developer Network: [setStart Method Article]