-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounter.html
More file actions
43 lines (41 loc) · 1.15 KB
/
Counter.html
File metadata and controls
43 lines (41 loc) · 1.15 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Character Counter</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 50px;
}
input[type="text"] {
width: 300px;
padding: 8px;
font-size: 16px;
}
.counter {
margin-top: 10px;
font-size: 18px;
}
span {
color: red;
font-weight: bold;
}
</style>
</head>
<body>
<h2>Live Character Counter</h2>
<input type="text" id="a" placeholder="Type something here...">
<div class="counter">Characters typed: <span id="b">0</span></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
$(document).ready(function() {
$("#a").keyup(function() {
let charCount = $(this).val().length;
$("#b").text(charCount);
});
});
</script>
</body>
</html>