Last active
March 22, 2016 19:35
-
-
Save accrane/fe32370e15dca649674f to your computer and use it in GitHub Desktop.
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
<script> | |
$(document).ready(function() { | |
$('.js-title').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.pop(); // pop the last word | |
first_part = word_array.join(' '); // rejoin the first words together | |
heading.html([first_part, ' <span class="last-word">', last_word, '</span>'].join('')); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment