Counting letters / characters in jQuery -


i searched online , looked @ api docs on how count characters, , i'm using this: $('.test').val().length;

however, it's not working @ all.

my div looks this: <div class="test">count these letters</div>

i expect $('.test').val().length; return 19, instead returning 1... using wrong function?

for text, you'll need .text(), this:

 $('.test').text().length 

Comments