This method ...
window.getSelection().anchorNode
... tells us where the text STARTS is fetched.
This method ...
window.getSelection().focusNode
... tells us where the ENDS text selection is located.
Since the text can choose to drag left-right or right-left, this does not mean that it anchorNodeis to the left of focusNode.
What DOM / JavaScript method can I use to define a node reference on the LEFT side to select text?
Clarification: this is a bug fix for method startContainer()( window.getSelection().getRangeAt(0).startContainer) and therefore this is an invalid suggestion.
John source
share