JSFiddle - React, Tailwind, and code Playground
by Lalji Tadhani
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css">
<div class="box">
<span class="input">
These, are, 7, words, as, a, demonstrationd, demonstrationd,12,13,15,15
</span>
<br>
<br>
<span class='output'>
</span>
<br>
<br>
</div>
<div class="box">
<span class="input">
These, are, 7, words, as, a, demonstration,12
</span>
<br>
<br>
<span class='output'>
</span>
</div>
JavaScript
$(function() {
$(".input").each(function(element) {
var text = $(this).text();
var wordsCount = text.split(',').length;
$(this).parent().find('.output').html('word count:' + wordsCount);
});
});