I'm looking for a way to display a paragraph of text and allow a user to click on a individual word to highlight it.
I found some code that will place a span around each word. And all of this works great, but...
When I have some text like say Soufflé it doesn't recognize it as one just one word.
Here is the code I'm using.
var p = $('#storyText');
p.html(function(index, oldHtml) {
return oldHtml.replace(/\b([\w+-éñó\u00F1\u00E9]+)\b/g, '< span class="storyWord">$1< /span>');
})
It seems to work fine until I have an accent at the beginning or ending of a word.