1

Is it possible with pure JavaScript, to select part of a text within a and through a function, return the number of characters that were selected?

For the example below, selecting "banana" somehow returns "Total Chars Selected: 6 chars".

<textarea id="my_textarea" name="my_textarea" rows="10" cols="50">Apple Banana Orange</textarea>

Intended Result:

Example

Edgaras
  • 404
  • 2
  • 16
  • This has been closed as a duplicate, but the 'duplicate' is a different question. This asks how to count the number of characters selected - the other question asks how to count the number of characters entered. – Chris Lear Feb 20 '21 at 17:15
  • You can use this answer: https://stackoverflow.com/questions/6416020/javascript-get-selected-text-from-any-textinput-textarea-on-the-page just use the length from the return value – zb22 Feb 20 '21 at 17:15

0 Answers0