Get Selected Text with JavaScript: Quick & Easy Tutorial
HTML-код
- Опубликовано: 13 июл 2024
- 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:
developer.mozilla.org/en-US/d...
🏫 My Udemy Courses - www.udemy.com/user/domenic-co...
🎨 Download my VS Code theme - marketplace.visualstudio.com/...
💜 Join my Discord Server - / discord
🐦 Find me on Twitter - / dcodeyt
💸 Support me on Patreon - / dcode
📰 Follow me on DEV Community - dev.to/dcodeyt
📹 Join this channel to get access to perks - / @dcode-software
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
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.
Thank bro❤
❤
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).
👑 how can i let user highlight the selected text?
Хорош 👍
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)