Skip to content

Commit 29201a6

Browse files
committed
Section 20: Binding Events in a Class
1 parent 70b9b1a commit 29201a6

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Timer</title>
8+
</head>
9+
<body>
10+
<input id="duration" />
11+
<button id="start">Start</button>
12+
<button id="pause">Pause</button>
13+
<script src="index.js"></script>
14+
</body>
15+
</html>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// ******************************
2+
// What on Earth are Prototypes ******************************
3+
4+
class Timer {
5+
constructor(durationInput, startButton, pauseButton) {
6+
this.durationInput = durationInput
7+
this.startButton = startButton
8+
this.pauseButton = pauseButton
9+
10+
// start(){}, Calling the constructor anytime the user clicks on the start button
11+
this.startButton,addEventListener('click', this.start)
12+
}
13+
14+
start() {
15+
console.log('Time to start the timer!');
16+
}
17+
}
18+
19+
const durationInput = document.querySelector('#duration')
20+
const startButton = document.querySelector('#pause')
21+
const pauseButton= document.querySelector('#pause')
22+
23+
// Create our instance of the timer and pass in those three elements
24+
const timer = new Timer(durationInput, startButton, pauseButton)

20-Drawing-Animations/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## 19-Prototypes-Classes-And-The-New-Operator
2+
3+
## 1. 06 Binding Events in a Class
4+
5+
##

0 commit comments

Comments
 (0)