JSFiddle - React, Tailwind, and code Playground
by bizamajig
HTML
<input id="a" type="text" value="Hello world" /><br/>
<input id="b" type="text" /><br/>
<input id="c" type="text" value="Goodbye" /><br/>
<input id="finalcount" value="0" disabled />
JavaScript
$(function() {
var wordCounts = {};
$("input[type='text']:not(:disabled)").keyup(function() {
var matches = this.value.match(/\b/g);
wordCounts[this.id] = matches ? matches.length / 2 : 0;
var finalCount = 0;
$.each(wordCounts, function(k, v) {
finalCount += v;
});
$('#finalcount').val(finalCount)
}).keyup();
});