javascript - JS: Record user selections in html with multiples occurrence -
i'm trying record user highlighting in node, giving can multiples children nodes , part of text can duplicated , need differentiated.
<div id="blob"> <p>this text lots of <b>content</b>!</p> <p>there can <span>lots</span> of paragraph , weird things</p> <p>there duplicates in text:</p> <p>this text lots of <b>content</b>!</p> <div>the goal record text selected, , know it's position (n° of occurrence) in blob of text</div> </div>
for example, if user selected 'with lots of content', need know part of text refer too.
my current implementation put tags on selection text, , theirs positions relative overall text, , index of research of selected text. seems hacky, requires modify html. there way without it?
it's related "javascript-find-occurance-position-of-selected-text-in-a-div" without assumption parent node text node.
Comments
Post a Comment