Count Characters Left


The keyup() event decrease the length of characters in the status box. How is the character counter increased after pressing 'Backspace' or deleting a character?

        var postLength = $(this).val().length;
        var charactersLeft = 140-postLength;


Every event results in a new character count of the text in the form control. Backspace or delete will reduce the count since they are not printing characters.


Yes but where is the code for reducing the count?


postLength gets redeclared and set on every handled event. charactersLeft, likewise. There is no running variable to increase or decrease.