JSFiddle - React, Tailwind, and code Playground
HTML
<div id="foo">Hello I am a text. I have no clue why I am here or what I am good for, but I have QUOTES and other things I can offer.</div>
JavaScript
$('#foo').contents().each(function(_, node) {
var nodelist = node.textContent.split(/\s/).map(function( word ) {
return $('<span>', {
text: word + ' ',
click: function() {
alert( $(this).text() );
}
}).get(0);
});
$('#foo').empty().append(nodelist);
});