Skip to content

Instantly share code, notes, and snippets.

Created Aug 2, 2019
What would you like to do?
jQuery Text Counter
<!DOCTYPE html>
<html lang="ja">
<meta charset="utf-8">
<link rel="stylesheet" href="" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
.container {
width: 500px;
margin-top: 100px;
font-size: 18px;
#count1, #count2 {
color: grey;
<div class="container">
<div class="form-group">
<textarea id="countUp" class="form-control" rows="5"></textarea>
<span id="count1" class="float-right">0</span>
<div class="form-group">
<textarea id="countDown" class="form-control" rows="5"></textarea>
<span id="count2" class="float-right">30</span>
<script src=""></script>
var remain = 30 - $(this).val().length;
if (remain < 0) {
$('#count2').css('color', 'red');
} else {
$('#count2').css('color', 'grey');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment