onlinecode

find the number of characters in a string using jQuery

find the number of characters in a string using jQuery

In this post we will give you information about find the number of characters in a string using jQuery. Hear we will give you detail about find the number of characters in a string using jQueryAnd how to use it also give you demo for it if it is necessary.

Use the jQuery .length property


The jQuery .length property can be used to get or find out the number of characters in a string. You can also use this property to calculate the number of elements in a jQuery object.


Let’s take a look at an example to understand how it basically works:


<script>
    $(document).ready(function(){
        var myStr = "      Paragraph of text with   multiple white     spaces before and after.       ";
        myStr.length; // Returns 81
        $.trim(myStr).length; // Returns 68
        myStr.replace(/ /g,'').length; // Returns 53
    });
</script>


 

Hope this and post will helped you for implement find the number of characters in a string using jQuery. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and Keep reading our blogs

For More Info See :: laravel And github

Exit mobile version