Created
January 22, 2014 16:00
-
-
Save emaildano/8561356 to your computer and use it in GitHub Desktop.
Script and style to underline individual words.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1 span { | |
text-decoration: underline; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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