JSFiddle - React, Tailwind, and code Playground
by gabrieleromanato
HTML
<h1>Lorem ipsum dolor sit amet</h1>
<h1>Et ideo autem ipsum dolor sit amet</h1>
CSS
h1 span {
text-decoration: underline;
}
JavaScript
$(function() {
$('h1').each(function() {
var words = $(this).text().split(' ');
$(this).empty().html(function() {
for (i = 0; i < words.length; i++) {
if (i == 0) {
$(this).append('<span>' + words[i] + '</span>');
} else {
$(this).append(' <span>' + words[i] + '</span>');
}
}
});
});
});