-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathcharacter.html
More file actions
71 lines (68 loc) · 1.59 KB
/
character.html
File metadata and controls
71 lines (68 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style type="text/css">
@font-face {font-family: 'Oswald';font-style: normal;font-weight: 400;src: local('Oswald Regular'), local('Oswald-Regular'), url(https://themes.googleusercontent.com/static/fonts/oswald/v8/-g5pDUSRgvxvOl5u-a_WHw.woff) format('woff');}
#text-box{
width:50%;
background:#ddd;
border:1px solid #bbb;
padding:8px;
margin:30px auto 0;
text-align:center;
}
#text{
width:99%;
height:200px;
}
#text:focus{
outline:none;
}
#count{
text-align:center;
font:20px Oswald;
background:#fff;
color:#555;
border:1px solid #aaa;
display:block;
padding:2px 0;
margin:3px auto 0;
}
.judul{
text-align:center;
font:24px Oswald;
color:#555;
padding:0;
margin-bottom:8px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
<div id="text-box">
<div class="judul">Character Count Tool</div>
<textarea id="text" placeholder="Paste Character Here"></textarea>
<div id="count">Count: 0 Character</div>
</div>
<script>
$(document).ready(function(){
$(function() {
window.charCount = 0;
setInterval(function() {
var cc = charCount($('#text').val())
if(cc != window.charCount) {
window.charCount = cc;
$("#count").html("Count: " + window.charCount + " Characters");
}
}, 500);
});
function charCount(str) {
if (str === "")
return 0;
return $.trim(str).length
}
});
</script>
</body>
</html>