Get Selected Text with JavaScript: Quick & Easy Tutorial

preview_player
Показать описание
In this video, let's have a look at how to get the currently selected text on a web page using JavaScript. I'll also be showing you how to react to when your user changes their text selection.

For your reference, check this out:

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!

#dcode #javascript
Рекомендации по теме
Комментарии
Автор

I've observed various scenarios for using selected text, such as sharing it on social media etc. Although I'm not utilizing this feature at the moment, I have several ideas on how to integrate it into my own application(s).

TomasMisura
Автор

Looks interesting. I most often see the "copy text" option when you want to copy code, for example, by just clicking a button, but without needing to select anything first. I guess this would be useful depending on the specific app.

MrBrady
Автор

How can I create a popup from selected text providing several options that can be actioned on, such as making a note on selected text?

cryptixdaemon
Автор

👑 how can i let user highlight the selected text?

codein
Автор

This doesn't work at:
- If the element has shadow dom and the elements in its shadow root also has shadow doms (nested shadoe doms)
- selected text in google docs (rendered in a canvas)
- word online (has specific way to render items)

tahasoft