Created
February 13, 2019 22:58
-
-
Save justinallen/636a918ea289647307ff006b6862bd12 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
// great little typographic widow control script from chris coyier | |
// https://css-tricks.com/preventing-widows-in-post-titles | |
$("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