-
-
Save codingwithsara/3564a0c2879f25e2ed434e5397123fa3 to your computer and use it in GitHub Desktop.
jQuery Text Counter
This file contains 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
<script> | |
$(function(){ | |
$('#countUp').keyup(function(){ | |
$('#count1').text($(this).val().length); | |
}); | |
$('#countDown').keyup(function(){ | |
var remain = 30 - $(this).val().length; | |
$('#count2').text(remain); | |
if (remain < 0) { | |
$('#count2').css('color', 'red'); | |
} else { | |
$('#count2').css('color', 'grey'); | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment