Skip to content

Instantly share code, notes, and snippets.

@accrane
Last active March 22, 2016 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save accrane/fe32370e15dca649674f to your computer and use it in GitHub Desktop.
Save accrane/fe32370e15dca649674f to your computer and use it in GitHub Desktop.
<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