Created
January 14, 2014 04:01
-
-
Save dznz/8412835 to your computer and use it in GitHub Desktop.
Count down the number of characters that remain in a text box.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ -> | |
$body = $('#question_body') | |
$counter = $('#js-body-count') | |
determineChange = -> | |
remainingChars = 140 - $body.val().length | |
if remainingChars isnt 140 | |
$counter.text remainingChars | |
else | |
$counter.text "" | |
$body.keyup determineChange | |
$body.keypress (e) -> | |
setTimeout -> | |
determineChange | |
, 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment