Last active
September 30, 2016 10:21
-
-
Save amnuts/b1cab862e7c126737f38 to your computer and use it in GitHub Desktop.
word/char count w/ jquery
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
$(function(){ | |
var txt = $('.content')[0].text(), | |
charCount = txt.length, | |
wordCount = txt.replace(/[^\w ]/g, "").split(/\s+/).length; | |
$('#somwhereInYourDocument').text("The text had " + charCount + " characters and " + wordCount +" words"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment