JSFiddle - React, Tailwind, and code Playground
HTML
<textarea name="texto"></textarea>
<button id="count">Count</button>
JavaScript
$('#count').on({
'click': function(){
var value = $.trim($('[name="texto"]').val()),
count = value == '' ? 0 : value.split(' ').length;
alert(count);
}
});