Sorry for reading wrong your question @siouxfan45!
here is the right answer:
just a little improvement in your code and you can count words!
just change these two lines:
jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length);
to this:
jQuery("#excerpt_counter").val(jQuery("#excerpt").val().split(/\S\b[\s,\.\'-:;]*/).length - 1);
Words with single quote like “don’t”, “it’s”, “I’d”, “won’t”…will count as two!
If you want them to count as a single word, then you will want to change the .split()
to this:
.split(/\S+\b[\s,\.\'-:;]*/)
Hope I’m right this time!