Created
November 17, 2016 20:47
-
-
Save budparr/c68732f06b103f70ae26e37881e6e38b to your computer and use it in GitHub Desktop.
widow control script
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
//control widows, ala www.css-tricks.com/preventing-widows-in-post-titles/ | |
$("ID").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