Hello bold World
|
|
var range = document.createRange()
range.selectNode(refNode)
- selects a refNode including all its children.range.selectNodeContents(refNode)
- selects only the children of a refNode.var sel = window.getSelection().
var range = sel.getRangeAt(0)
startContainer
- the parent of the first node in the selection.startOffset
- the number of characters skipped before the range starts if startContainer
is a text node; otherwise it's the index of the first child node in the range.endContainer
- the parent of the last node in the selection.endOffset
- the number of characters skipped before the range ends if endContainer
is a text node; otherwise it's the index of the last child node in the range.commonAncestorContainer
- the first node that contains both startContainer
and endContainer
.range.setStartBefore(refNode)
range.setStartAfter(refNode)
range.setEndBefore(refNode)
range.setEndAfter(refNode)