[Home] >  Snippets >  Browser >  DOM >  Get the selected text

Get the selected text

JavaScript version

const getSelectedText = () => window.getSelection().toString();