This is just a char counter
(later on I will count words) for the value of the textarea
.
The currentLenght
variable is not defined. I have tried to have it in the global and local scope, but I get the same error.
Upon clicking the left span, this calls the getCharLenght
fn and should update the "result" span with the value.
Here is the JS:
getCharacters.addEventListener("click", getCharLenght());
function getCharLenght() {
contentBox.addEventListener("input", function() {
if (currentLength > 0) {
result.innerHTML = currentLength;
result.style.opacity = 1;
} else {
result.style.opacity = 0;
}
});
}
And here is the pen:
https://codepen.io/damianocel/pen/LLwvBL
Why is this happening, I am aware of hoisting and scope(more or less).