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

Комментарии • 7

  • @MrBrady95
    @MrBrady95 2 месяца назад

    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.

  • @ashutoshpardeshi23
    @ashutoshpardeshi23 2 месяца назад

    Thank bro❤

  • @offgridvince
    @offgridvince 2 месяца назад +1

  • @TomasMisura
    @TomasMisura 2 месяца назад +1

    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).

  • @codein7764
    @codein7764 2 месяца назад

    👑 how can i let user highlight the selected text?

  • @virtuoz-ru
    @virtuoz-ru 2 месяца назад

    Хорош 👍

  • @tahasoft1
    @tahasoft1 Месяц назад

    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)