I know tha开发者_StackOverflow中文版t usually you want to strip these out, but I need the true char count and I can't find out how to get it...
Thanks for the help
Keith, I wrote a quick tutorial about this some weeks ago which will likely have the snippet you need. The demo is at this page and the tutorial is here. Hope this helps.
Use the length
property on any string to get its character count. E.g.
'this is an example string'.length // == 26
or, for jQuery:
$('#my_textarea').html().length
N.B. use html()
not text()
to avoid having jQuery do things like removing line-breaks.
What's wrong with .length
? That counts line breaks as characters (I assume you meant a line break by 'ENTER'?)
This plugin seems to do the job.
It counts words too.
精彩评论