How to get the currently selected text in Javascript

Posted . Visible to the public.

Simple:

window.getSelection().toString();

Browser support: IE9+, Android 4.3+, Safari 5+

Profile picture of Dominik Schöler
Dominik Schöler
Last edit
Dominik Schöler
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2017-02-10 11:20)