JS

TEXTAREA REMAINING CHARACTERS COUNTER

<div class="char-remain" id="demo"> USUAL TEXT AREA <textarea maxlength="160" class="char-remain-txt"></textarea>   REMAINING COUNTER <div class="char-remain-count"></div> </div>

THE HTML

01

GET TEXTAREA + REMAINING COUNTER  let textarea = document.querySelector ("#demo .char-remain-txt"), remain = document.querySelector ("#demo .char-remain-count");

THE JAVASCRIPT

02

INIT REMAINING CHARACTERS remain.innerHTML = textarea.maxLength; 

CALCULATE REMAINING CHARACTERS textarea.addEventListener("keyup", () => {   remain.innerHTML = textarea.maxLength    - textarea.value.length; });