I have: A 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 to: move a word to a range when the user clicks on it.
Ie User clicked on a 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 this? Is there a more efficient way that just puts all words in a range at boot time?
PS I'm not interested window.getSelection()
because I want to specify a specific style for the affected words, as well as save a set of affected words
Especially for @DavidThomas: an example where I get selected text but don’t know how to wrap it in span .