-
-
Save codingwithsara/f903874eaed6177b75e3c2aff3d9bb59 to your computer and use it in GitHub Desktop.
JavaScript 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 count_up(obj) { | |
document.getElementById('count1').innerHTML = obj.value.length; | |
} | |
function count_down(obj) { | |
var element = document.getElementById('count2'); | |
element.innerHTML = 30 - obj.value.length; | |
if (30 - obj.value.length < 0) { | |
element.style.color = 'red'; | |
} else { | |
element.style.color = 'grey'; | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment