Skip to content

Instantly share code, notes, and snippets.

@pheuter
Created January 4, 2011 05:19
Show Gist options
  • Save pheuter/764427 to your computer and use it in GitHub Desktop.
Save pheuter/764427 to your computer and use it in GitHub Desktop.
Wordcount bookmarklet
document.body.appendChild(document.createElement('script')).src='http://code.jquery.com/jquery-1.4.3.min.js';
setTimeout(function () {
$("textarea").after(function () {
return "<p style='color:blue;'>Word count: <b>"+$(this).val().split(/\s+/).length+"</b></p>"
});
wc = function(ta) { ta.siblings().html('Word count: <b>'+ta.val().split(/\s+/).length+'</b>'); };
$("textarea").keypress(function() {
wc($(this));
}
)},500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment