-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvanilla-7.html
35 lines (28 loc) · 962 Bytes
/
vanilla-7.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Vanilla js project 2 alt</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body class="container">
<form class="pt-2">
<div class="form-group">
<label for="text">Enter your text below.</label>
<textarea id="text" class="form-control"></textarea>
</div>
</form>
<p>You've written <strong><span id="character-count">0</span> characters</strong>.</p>
<script>
var area = document.querySelector('#text');
var counter = document.querySelector('#character-count');
//console.log(counter);
area.addEventListener('input', function(){
// textLength is a textarea specific property
let nrOfChars = area.textLength;
//console.log(nrOfChars);
counter.textContent = nrOfChars;
})
</script>
</body>
</html>