
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!