Created
March 6, 2017 16:17
-
-
Save accrane/53ffdc88f7b062c6cce2e4efacd5693b to your computer and use it in GitHub Desktop.
jQuery solution to changing the styling of the first word
This file contains 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
/* | |
* | |
* Make first word in date underlined | |
* | |
------------------------------------*/ | |
$('.js-first-word').each(function(index, element) { | |
var heading = $(element); | |
var word_array, last_word, first_part; | |
word_array = heading.html().split(/\s+/); // split on spaces | |
last_word = word_array.shift(); // shift the first word | |
first_part = word_array.join(' '); // rejoin the first words together | |
heading.html(['<span class="e-date">', last_word, '</span> ' , first_part].join('')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment