So this is the functionality I need to clean up:
I need to create a function where viewers can click on any word in a sentence, and it will be highlighted. However,
This could maybe work if the amount of content is limited else you might experience some lag onload.
Start out by gathering all the elements that need this ability into an array. Split each sentence using " " as the variable into another temporary array. Step through temp array adding a span tag around each word with a new class. Then return the new string with span tags to the corresponding element. This can be down with 2 for loops. Last bind both hover and onclick to each new tag by using another for loop. Sorry no code, I'm watching tosh lol, but if you make a jsfiddle I will write it for you.
Like I said this shouldn't be done with a lot of sentences at one time. You could always stagger sentences if you have multiple sections.
Hope this helps explain how I would do it. Good luck let me know what happens!