--- title: getSelectedText tags: browser,beginner --- Gets the currently selected text. - Use `Window.getSelection()` and `Selection.toString()` to get the currently selected text. ```js const getSelectedText = () => window.getSelection().toString(); ``` ```js getSelectedText(); // 'Lorem ipsum' ```