I am trying to replace specific highlighted(marked) text from element.
This is how I get the highlighted text so far:
var markArea = $('.ElementText textarea').get(0);
var text = markArea.value.substring(markArea.selectionStart, markArea.selectionEnd);
So if I have something like this in the textarea: "apple banana apple orange" and mark the third word (apple) I want to replace exactly what I have marked without any other occurrences of "apple" in the textarea.
Is there a way to specify the start and end area where the code should look for replacement in the string?