Add 'Character count' project
This commit is contained in:
parent
c9f3c0d80e
commit
23adb32b98
4 changed files with 34 additions and 0 deletions
9
js-essentials/character-count/README.md
Normal file
9
js-essentials/character-count/README.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# Character count
|
||||||
|
|
||||||
|
Display the number of characters a user has typed into a textarea
|
||||||
|
element in real time as they type.
|
||||||
|
|
||||||
|
# Reference
|
||||||
|
|
||||||
|
* https://leanwebclub.com/learn/js-essentials/project-character-count/
|
||||||
|
|
17
js-essentials/character-count/index.html
Normal file
17
js-essentials/character-count/index.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" data-bs-theme="dark">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
|
||||||
|
<title>Character count</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Character count</h1>
|
||||||
|
<label for="text">Enter your text below.</label>
|
||||||
|
<textarea id="text"></textarea>
|
||||||
|
<p>You've written <strong><span id="character-count">0</span> characters</strong>.</p>
|
||||||
|
|
||||||
|
<script src="script.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
7
js-essentials/character-count/script.js
Normal file
7
js-essentials/character-count/script.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
let counter = document.querySelector("#character-count");
|
||||||
|
let textarea = document.querySelector('#text');
|
||||||
|
|
||||||
|
textarea.addEventListener('input', function (event) {
|
||||||
|
counter.innerText = event.target.value.length;
|
||||||
|
});
|
||||||
|
|
|
@ -12,6 +12,7 @@ func main() {
|
||||||
mux.Handle("GET /toggle-password-visibility/", http.StripPrefix("/toggle-password-visibility", http.FileServer(http.Dir("toggle-password-visibility"))))
|
mux.Handle("GET /toggle-password-visibility/", http.StripPrefix("/toggle-password-visibility", http.FileServer(http.Dir("toggle-password-visibility"))))
|
||||||
mux.Handle("GET /toggle-multiple-fields/", http.StripPrefix("/toggle-multiple-fields", http.FileServer(http.Dir("toggle-multiple-fields"))))
|
mux.Handle("GET /toggle-multiple-fields/", http.StripPrefix("/toggle-multiple-fields", http.FileServer(http.Dir("toggle-multiple-fields"))))
|
||||||
mux.Handle("GET /toggle-multiple-forms/", http.StripPrefix("/toggle-multiple-forms", http.FileServer(http.Dir("toggle-multiple-forms"))))
|
mux.Handle("GET /toggle-multiple-forms/", http.StripPrefix("/toggle-multiple-forms", http.FileServer(http.Dir("toggle-multiple-forms"))))
|
||||||
|
mux.Handle("GET /character-count/", http.StripPrefix("/character-count", http.FileServer(http.Dir("character-count"))))
|
||||||
|
|
||||||
log.Println("Start the web server...")
|
log.Println("Start the web server...")
|
||||||
err := http.ListenAndServe(":8080", mux)
|
err := http.ListenAndServe(":8080", mux)
|
||||||
|
|
Loading…
Reference in a new issue