Count of Characters in a String using jQuery

jquery new tab

In this tutorial , I will explain you how to count of characters in string.

Generally, there is necessary to count the string in field. and show the value of string.

So let’s start our tutorial


<!DOCTYPE html>
<html>
<head>
    <title>Count of Characters in a String using jQuery - oakml.com</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<h1>Count of Characters in a String using jQuery - oakml.com</h1>
<input type="text" name="message" value="Helloooo ! How are you ?" class="message">
<button class="button">Count The String</button>
<script>
    $(document).ready(function(){
        $('.button').click(function(){
            var countheString = $('.message').val().length;
            alert(countheString);
        });
    });
</script>
</body>
</html>

I hope it will help you!

About Dhaval Shah

My name is Dhaval Shah. I'm a Laravel developer. I live in India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Java-script, JQuery, Laravel, WordPress, and Bootstrap.
Follow me on Github / Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!