Skip to content

Commit 92b6ee6

Browse files
author
Steven G. Harms
committed
Update for testable base
1 parent 488da47 commit 92b6ee6

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ It allows us to associate "hearing" an event with executing a callback.
2121
1. the name of the event
2222
2. a _callback function_ to "handle" the event
2323

24-
Start by adding a listener for `click` event on the `main#main` element
25-
in `index.html`. Take a look at `index.html` in the browser. When you
26-
click in the `main#main` area, nothing happens. Now let's set up
27-
some _event handling_.
24+
Take a look at `index.html` in the browser. When you click in the `<input>`
25+
area, nothing happens. Now let's set up some _event handling_.
2826

29-
Enter the following into `index.js`:
27+
Start by adding an event listener for the `click` event on the `input#input`
28+
element in `index.html`.
29+
30+
Try out the following in the Chrome DevTools console:
3031

3132
```js
3233
const main = document.getElementById('main');
@@ -36,7 +37,10 @@ main.addEventListener('click', function(event) {
3637
});
3738
```
3839

39-
When you click inside of `main#main`, **_now_**, you will get an alert box.
40+
When you click inside of `input#input`, **_now_**, you will get an alert box.
41+
42+
Take this code and paste it into the `index.js` file's `addingEventListener`
43+
function.
4044

4145
Let's review the parts of this code:
4246

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<main id="main">My ID is "main"!</main>
1818
<br />
1919
<div>
20-
<label>Input:</label><input />
20+
<label>Input:</label><input id="input" />
2121
</div>
2222
<br />
2323
<div>

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
function addingEventListener() {
2+
}

0 commit comments

Comments
 (0)