We can find the number of characters in a string using the length property of JQuery as follows:
1 2 3 4 5 6 7 8 |
$(document).ready(function(){ var myStr = " Paragraph of text with multiple white spaces before and after. "; myStr.length; // Returns 81 (Length of String Including White-spaces) $.trim(myStr).length; // Returns 68 (Length of String Without White-spaces) myStr.replace(/ /g,'').length; // Returns 53 (Length of String After Removing Beginning & Trailing White-spaces) }); |
Likes
(0)Dislikes
(0)


Shoot, who would have thoguht that it was that easy?