Reputation: 2368
I searched online and looked at the API Docs on how to count characters, and I'm currently using this: $('.test').val().length;
However, it's not working at all.
My div looks like this: <div class="test">Count These Letters</div>
I expect $('.test').val().length;
to return 19
, but instead its returning 1
... am I using the wrong function?
Upvotes: 1
Views: 71
Reputation: 9167
For text, you'll need .text()
, like this:
$('.test').text().length
Upvotes: 6