I have the code to display the number of words of each post. This code I can from @Hektor in this post. Thanks Hektor..
But I have a new problem when applying it on my blog.
Here are the codes:
<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js' type='text/javascript'></script>
<div class="post">abc def ghi jkl mno pqr stu</div>
<div id="box"></div>
<div id="box"></div> //That this does not work
<script>
function wordcount(){
var e = $(".post");
var totalWords = 0;
for (var i = 0; i < e.length; i++) {
var innerTx = e[i].innerHTML;
var wordArray = innerTx.split(' ');
var thisTotal = wordArray.length;
totalWords += thisTotal;
}
if (totalWords > 15 ) {
$("#box").html("15+ words");
}
else if(totalWords > 10){
$("#box").html("10-15 words");
}
else if(totalWords > 5){
$("#box").html("5-10 words");
}
else if(totalWords > 0){
$("#box").html("0-5 words");
}
}
wordcount();
</script>
If only placed one DIV, this works fine, but if for two div, it does not work.
There is a solution?