title: Detect which word has been clicked on within a text
body: <p>I am building a JS script which at some point is able to, on a given page, allow the user to click on any word and store this word in a variable.</p>
  
  <p>I have one solution which is pretty ugly and involves class-parsing using jQuery:
  I first parse the entire html, split everything on each space <code>" "</code>, and re-append everything wrapped in a <code>&lt;span class="word"&gt;word&lt;/span&gt;</code>, and then I add an event with jQ to detect clicks on such a class, and using $(this).innerHTML I get the clicked word.</p>
  
  <p>This is slow and ugly in so many ways and I was hoping that someone knows of another way to achieve this.</p>
  
  <p>PS: I might consider running it as a browser extension, so if it doesn't sound possible with mere JS, and if you know a browser API that would allow that, feel free to mention it !</p>
  
  <p>A possible owrkaround would be to get the user to highlight the word instead of clicking it, but I would really love to be able to achieve the same thing with only a click !</p>