I have: Simple block of html text:
<p>
The future of manned space exploration and development of space depends critically on the
creation of a dramatically more proficient propulsion architecture for in-space transportation.
A very persuasive reason for investigating the applicability of nuclear power in rockets is the
vast energy density gain of nuclear fuel when compared to chemical combustion energy...
</p>
I want: wrap word into span when user click on it.
I.e. User clicked at manned word, than I should get
<p>
The future of <span class="touched">manned</span> space exploration and development of space depends critically on the
creation of a ....
Question: How to do that? Is there way more efficient that just wrap all words into span at loading stage?
P.S. I'm not interested in window.getSelection()
because I want to imply some specific styling for touched words and also keep collection of touched words
Special for @DavidThomas: example where I get selected text, but do not know how to wrap it into span.
`. And a thousands of words inside it. Sorry, but how do you say you wanna wrap a word?
– VB_ Nov 14 '14 at 13:48