Skip to content

Instantly share code, notes, and snippets.

@riix
Created August 2, 2012 03:52
Show Gist options
  • Save riix/3233188 to your computer and use it in GitHub Desktop.
Save riix/3233188 to your computer and use it in GitHub Desktop.
Count Character
$(".countchars").each(function () {
var length = $(this).val().length;
$(this).parent().find('#charlength').html('<b>' + length + '</b>');
$(this).keyup(function () {
var new_length = $(this).val().length;
$(this).parent().find('#charlength').html('<b>' + new_length + '</b>');
if (new_length == "140") {
$('#charlength').css('background', 'red');
$('#charlength').css('color', '#000000');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment