Document.createRange()
Returns a new Range
object.
Syntax
JavaScript
Copy Code
range = document.createRange();
range
is the created Range
object.
Example
JavaScript
Copy Code
var range = document.createRange(); range.setStart(startNode, startOffset); range.setEnd(endNode, endOffset);
Notes
Once a Range
is created, you need to set its boundary points before you can make use of most of its methods.
Specification
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/document/createrange