const getSelectedText = () => window.getSelection().toString(); console.log(getSelectedText());
How to Get the User Selection Text on a Web Page
118
2 years ago
0 comments
If you want to get the text that a user selects or highlights on a web page, there is a useful one-liner for that and it's making use of the "window.getSelection" way.
Topics:
Frontend
Resource
Average
Average
Support Us
If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️
Leave a reply