Skip to content

Get selected text in JavaScript


In JavaScript we can get the text the user has selected using getSelection property

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

See also  Inserting and removing elements at a particular position from a JavaScript array

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.