Reputation: 1523
I may be missing something pretty obvious, but somehow I am struggling to count the characters inside a span tag. The span is dynamically populated and I am trying to get its lenght, spaces included, to adjust the width of a column. If I run only text() or html() I can get the content:
<span id="vlen00">someword</span>
vlenght = $('#vlen00').text();//vlenght is assigned 'someword'
vlenght = $('#vlen00').html();//this also gives me 'someword'
But when I tried to size it up like:
vlenght = $('#vlen00').text().lenght;//that gives me 'undefined'
vlenght = vlenght.lenght;//that also gives me 'undefined'
Thanks!
Upvotes: 0
Views: 2554
Reputation: 40318
change lenght to length.It will work
change
vlenght = $('#vlen00').text().lenght;
to
vlenght = $('#vlen00').text().length;
Upvotes: 2