Skip to main content

jQuery Simple Characters Counter

By Sam Deering

JavaScript

Share:

jQuery code snippet to show a live count of the number of characters that a user is inputting into the input field on a page.

jQuery Code

$(document).ready(function() {
    $("input[id='input-text']").keyup(function count(){
        counter = $("input[id='input-text']").val().length;
            $("#count").html(counter);
    });
});

HTML Code

See Live Demo

Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.

Integromat Tower Ad