The Selection.anchorNode read-only property returns the Node in which the selection begins.
Selection.anchorNode
MDN Reference