Skip to content

Instantly share code, notes, and snippets.

@codingwithsara
Created August 2, 2019 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingwithsara/3564a0c2879f25e2ed434e5397123fa3 to your computer and use it in GitHub Desktop.
Save codingwithsara/3564a0c2879f25e2ed434e5397123fa3 to your computer and use it in GitHub Desktop.
jQuery Text Counter
<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