JSFiddle - React, Tailwind, and code Playground
HTML
<textarea id="myTextarea" length="500"></textarea>
<span id="textareaLength"></span>
CSS
#myTextarea {
width: 300px;
height: 300px;
}
#textareaLength {
position: absolute;
}
JavaScript
var theCounter = $('#textareaLength'),
textarea = $('#myTextarea'),
maxLength = textarea.attr('length');
theCounter.text('0 / '+maxLength);
theCounter.css({
'top': (textarea.offset().top + textarea.height()) - theCounter.height(),
'left': (textarea.offset().left + textarea.width()) - theCounter.width()
});
textarea.on('keydown', function() {
var theLength = $(this).val().length;
theCounter.text($(this).val().length+' / '+maxLength)
.css({
'left': (textarea.offset().left + textarea.width()) - theCounter.width()
});
});