I 'de like to higlight text selected by the user and copy it over to a text box.
The latter part works great. But highlighting of the selected text fails if I try to highlight part of an already highlighted text.
Here's a JSFiddle Try selecting the text on the right box, then try to select part of your previous selection.
Any ideas?
The relevant code:
function highlightSelected() {
var selection = getSelected();
var range = selection.getRangeAt(0);
var newNode = document.createElement("span");
$(newNode).addClass('mark');
range.surroundContents(newNode);
return range;
}
Thanks !!