Skip to content

Instantly share code, notes, and snippets.

@LindseyWhitney
Created November 3, 2015 19:59
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 LindseyWhitney/fc1d80c51f94b417074d to your computer and use it in GitHub Desktop.
Save LindseyWhitney/fc1d80c51f94b417074d to your computer and use it in GitHub Desktop.
Removes orphans, so that a single word is never by itself on a line.
$("h2 a").each(function() {
var wordArray = $(this).text().split(" ");
if (wordArray.length > 1) {
wordArray[wordArray.length-2] += " " + wordArray[wordArray.length-1];
wordArray.pop();
$(this).html(wordArray.join(" "));
}
});
@LindseyWhitney
Copy link
Author

Original snippet found on CSS Tricks:
https://css-tricks.com/preventing-widows-in-post-titles/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment