How to count number of characters in a string with JQuery
In this tutorial, we are going to see how to count number of characters in a string with JQuery. JQuery’s .length property can be used to get the number of characters in a string. You can also use this property to calculate the number of items in a jQuery object.
How to count number of characters in a string with JQuery
$(document).ready(function(){
var str = " Lorem ipsum dolor fat amet, consectetur adipiscing muot. ";
console.log(str.length);
console.log($.trim(str).length);
console.log(str.replace(/ /g,'').length);
});
Output:
80 67 49




