Created
January 8, 2023 21:27
-
-
Save timhberry/ea2281d7163fff7c9662f6cd78e434c7 to your computer and use it in GitHub Desktop.
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
$('textarea').keyup(function() { | |
var characterCount = $(this).val().length, | |
current = $('#current'), | |
maximum = $('#maximum'), | |
theCount = $('#the-count'); | |
current.text(characterCount); | |
/*This isn't entirely necessary, just playin around*/ | |
if (characterCount < 70) { | |
current.css('color', '#666'); | |
} | |
if (characterCount > 70 && characterCount < 90) { | |
current.css('color', '#6d5555'); | |
} | |
if (characterCount > 90 && characterCount < 100) { | |
current.css('color', '#793535'); | |
} | |
if (characterCount > 100 && characterCount < 120) { | |
current.css('color', '#841c1c'); | |
} | |
if (characterCount > 120 && characterCount < 139) { | |
current.css('color', '#8f0001'); | |
} | |
if (characterCount >= 140) { | |
maximum.css('color', '#8f0001'); | |
current.css('color', '#8f0001'); | |
theCount.css('font-weight','bold'); | |
} else { | |
maximum.css('color','#666'); | |
theCount.css('font-weight','normal'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment