Powered by Blogger.

Saturday, October 28, 2017

How to find number of characters in a string using jQuery in asp.net?



Here we will discuss how to find number of characters in a string using jQuery in asp.net.

Here we will do this exercise inside an asp.net application.

Also you can read about:
- Array and ArrayList in C#.Net

- switch statement in C#.Net

- Add property to class in C#.Net

Below is the jQuery and JavaScript code.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnGetString").on("click", function () {
                var mainString = "This is our main string.";
                alert(mainString.length);
            });
        });
    </script>
    <br />
    <div class="row">
        <div class="col-md-4">
            <input type="button" id="btnGetString" value="Get Characters in string" /><br />
        </div>

    </div>

It will display the results like below:

jQuery find number of characters in string






0 comments

Post a Comment