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.onkeyup = function() {
var words = myWordsToCount.value.split(' ');
function wordCount(str) {
return str.split(' ').length;
}
//varmywordsToCount.addEventListener("keyup",function() {
//myTextareaElement.value = ' ';
console.log(wordCount('words++ '));
}
////wordCount.innerText = words.length;
//
//
//
//
//