I use this jQuery function to wrap words with <span> in each p element:
$("p").each(function(){
var text = $(this).text().split(' ');
for(var i = 0, len = text.length; i < len; i++ ) {
text[i] = '<span class="outline">' + text[i] + '</span>';
}
$(this).html(text.join(' '));
});
span{
color: blue;
}
strong{
color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p>We invest with <strong>capital,</strong></p>
<p><strong>know-how, experience</strong></p>
<p><strong>and ambition.</strong></p>
However it removes <strong> from DOM.
I need <strong> tag to stay in DOM even if <span> tag will be generated inside or outside of <strong>