# getSelectedText

Canonical: https://www.wiki.jodisand.me/snippets/javascript/getselectedtext/


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'
```


