JSFiddle - React, Tailwind, and code Playground
by Jordan Marechal
HTML
<textarea id="myWordsToCount" rows="5" cols="60"></textarea>
<span id ="WordCount">0</span> words
JavaScript
"use strict";
console.clear();
var WordCount = document.getElementById("WordCount");
var myTextareaElement = document.getElementById("myWordsToCount");
myTextareaElement.value = ' ';
//myTextareaElement.onkeyup = function() {
function myWordsToCount(str) {
my wordsToCount.addEventListener("keydown",function()){
var wordCount = myTextareaElement.value.split(' ');
myWordsToCount.innerText = wordCount.length;
return str.split(' ').length;
}
console.log(myTextareaElement);
}
};
//