Use to count letters. .keyup()
$('#area').keyup(function(){
$('.word-counter').text($.trim(this.value.length)+'/100');
})
And an attribute maxlengthfor maximum letters.
<div class="box">
<textarea name="" id="area" maxlength="100"></textarea>
<div class="word-counter">0/100</div>
</div>
Demo script
* Note. This supports spaces. If you need to handle only the number of letters, you can control keyup().
$('#area').keyup(function(){
$('.word-counter').text(this.value.replace(/ /g,'').length+'/100');
})
Fiddle (spaces are ignored in the number of letters)
source
share