Skip to content

Instantly share code, notes, and snippets.

@emaildano
Created January 22, 2014 16:00
Show Gist options
  • Save emaildano/8561356 to your computer and use it in GitHub Desktop.
Save emaildano/8561356 to your computer and use it in GitHub Desktop.
Script and style to underline individual words.
h1 span {
text-decoration: underline;
}
$('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>');
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment