Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save njm2112/670640196e11681c26661503cb48dd40 to your computer and use it in GitHub Desktop.
Save njm2112/670640196e11681c26661503cb48dd40 to your computer and use it in GitHub Desktop.
Style Blockquotes based on Wordcount
<script src="/js/jquery-1.8.3.min.js"></script>
// A little clever jQuery styling of blockquotes
<script>
$('blockquote p').each(function(){
var $numWords = $(this).text().split(" ").length;
console.log($numWords)
if ($numWords >= 25) {
$(this).css("text-align", "left");
$(this).css("padding-left", "1em");
}
else {
$(this).css("font-size", "1.3em");
}
if ($numWords >= 50) {
$(this).css("font-size", "0.7em");
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment