Window.getSelection()
and Selection.toString()
to get the currently selected text.const getSelectedText = () => window.getSelection().toString();
getSelectedText(); // 'Lorem ipsum'
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️