var countdown = document.getElementById("counterFooter");
document.getElementById("string").addEventListener("input", addText);
function addText(el) {
inputTxt = el.target.value;
changeCount();
}
function changeCount() {
let button = document.getElementById("btn");
currentLen = inputTxt.length;
countdown.innerHTML = currentLen + "/140";
if (currentLen >= maxTxt - 20) {
countdown.style.color = "red";
}
else {
countdown.style.color = "white";
}
if (currentLen >= maxTxt) {
button.disabled = true;
button.style.backgroundColor = "grey"
}
else {
button.disabled = false;
button.style.backgroundColor = "rgb(29, 161, 242)";
}
}
var maxTxt = 140;
var currentLen = 0;
var inputTxt = document.getElementById("string");