JSFiddle - React, Tailwind, and code Playground
HTML
<textarea name="txtScript" id="word_count" cols="30" rows="10"></textarea>
<br>
Total word Count : <span id="display_count">0</span> words. Words left : <span id="word_left">200</span>
JavaScript
$(document).ready(function() {
$("#word_count").on('keydown', function(e) {
var words = $.trim(this.value).length ? this.value.match(/\S+/g).length : 0;
if (words <= 200) {
$('#display_count').text(words);
$('#word_left').text(200-words)
}else{
if (e.which !== 8) e.preventDefault();
}
});
});