Created
November 3, 2015 19:59
-
-
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.
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
$("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(" ")); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original snippet found on CSS Tricks:
https://css-tricks.com/preventing-widows-in-post-titles/