Skip to content

Commit 9010947

Browse files
committed
Book 4, chapter 11
1 parent d148189 commit 9010947

File tree

6 files changed

+18
-71
lines changed

6 files changed

+18
-71
lines changed

bk04ch10/example01.html

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
</style>
1212
</head>
1313
<body>
14-
<footer>
15-
14+
<footer>
1615
</footer>
1716
<script>
18-
const pageFooter = document.querySelector("footer');
17+
const pageFooter - document.querySelector("footer");
1918
</script>
2019
</body>
2120
</html>

bk04ch11/example13.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<title>Setting the focus</title>
5+
<title>Monitoring the focus event</title>
66
<style>
77
* {
88
margin: 0;

bk04ch11/example14.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<title>Handling and Triggering Form Events</title>
5+
<title>Monitoring the blur event</title>
66
<style>
77
* {
88
margin: 0;

bk04ch11/example15.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<title>Handling and Triggering Form Events</title>
5+
<title>Listening for element changes</title>
66
<style>
77
* {
88
margin: 0;
@@ -24,8 +24,8 @@
2424
<input id="bgcolor" type="color" name="bg-color" value="#ffffff">
2525
</form>
2626
<script>
27-
document.querySelector('#bgcolor').addEventListener('change', function() {
28-
let backgroundColor = this.value;
27+
document.querySelector('#bgcolor').addEventListener('change', (event) => {
28+
let backgroundColor = event.target.value;
2929
document.body.bgColor = backgroundColor;
3030
});
3131
</script>

bk04ch11/example16.html

+11-9
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,22 @@
2626
</style>
2727
</head>
2828
<body>
29-
<button>
30-
Run Me!
31-
</button>
29+
<form>
30+
<button type="button">
31+
Run Me!
32+
</button>
33+
</form>
3234
<p>
33-
Keyboard shortcut: Ctrl+Shift+B
35+
Keyboard shortcut: Ctrl+Shift+E
3436
</p>
3537
<script>
3638
// Add a listener for the button's 'click' event
3739
document
3840
.querySelector('button')
3941
.addEventListener('click',
40-
function() {
42+
(event) => {
4143
// Change the button text
42-
this.innerText = 'Thanks!';
44+
event.target.innerText = 'Thanks!';
4345

4446
// Reset the button after 3 seconds
4547
setTimeout(() => document
@@ -51,9 +53,9 @@
5153
// Add a listener for the 'keydown' event
5254
document
5355
.addEventListener('keydown',
54-
function(e) {
55-
// Check to see if Ctrl+Shift+B are all pressed
56-
if(e.ctrlKey && e.shiftKey && e.key === 'B') {
56+
function(event) {
57+
// Check whether Ctrl+Shift+E are all pressed
58+
if(event.ctrlKey && event.shiftKey && event.key === 'E') {
5759
// If so, trigger the button's 'click' event
5860
document.querySelector('button').click();
5961
}

bk04ch11/example17a.html

-54
This file was deleted.

0 commit comments

Comments
 (0)