Javascript What Does Range.endoffset() Give You?
When I go: range.selectNodeContents(element); My understanding is that the range object selects all the contents of element. So that would mean that if I said: range.startOffset(
Solution 1:
The Range.endOffset read-only property returns a number representing where in the Range.endContainer the Range ends.
From: https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
Solution 2:
When you use selectNodeContents
,
- Let length be the length of node.
- Set end to the boundary point (node, length).
So the end offset is set to the length of the node:
To determine the length of a nodenode, switch on node:
DocumentType Zero.
Text, ProcessingInstruction, Comment The number of code units in its data.
Any other node Its number of children.
That's what you will get you you call endOffset
.
Post a Comment for "Javascript What Does Range.endoffset() Give You?"