JSFiddle - React, Tailwind, and code Playground

HTML

<textarea class="message" rows="2" cols="30" maxlength="140"></textarea>
<span class="countdown"></span>

JavaScript

jQuery(document).ready(function ($) {
    updateCountdownAll();
    $('.message').live('input', updateCountdown);

});

function updateCountdownAll() {
    $('.message').each(function () {
        updateCountdown(this);
    });
}

function updateCountdown(e) {

    var currentElement;
    if (e.target) {
        currentElement = e.target;
    } else {
        currentElement = e;
    }

    var maxLengh = $(currentElement).attr('maxlength');
    var remaining = maxLengh - $(currentElement).val().length;
    $(currentElement).nextAll('.countdown:first').text(remaining + ' characters remaining.');
}