Is it possible in JavaScript to know if the text of a specified DOM element is selected/highlighted by the user? I don't want to get the selected text (like in Get the Highlighted/Selected text), but just know if the element is selected/highlighted.
Asked
Active
Viewed 108 times
0
-
2Yes, it is. – Niet the Dark Absol Nov 21 '16 at 17:10
-
1With [`getSelection`](https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/getSelection) and [`containsNode`](https://developer.mozilla.org/en-US/docs/Web/API/Selection/containsNode). – Sebastian Simon Nov 21 '16 at 17:12
-
containsNode is exactly what I was looking for! Thanks. – johanvs Nov 21 '16 at 17:19