File tree 3 files changed +13
-7
lines changed
3 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -21,12 +21,13 @@ It allows us to associate "hearing" an event with executing a callback.
21
21
1 . the name of the event
22
22
2 . a _ callback function_ to "handle" the event
23
23
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_ .
28
26
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:
30
31
31
32
``` js
32
33
const main = document .getElementById (' main' );
@@ -36,7 +37,10 @@ main.addEventListener('click', function(event) {
36
37
});
37
38
```
38
39
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.
40
44
41
45
Let's review the parts of this code:
42
46
Original file line number Diff line number Diff line change 17
17
< main id ="main "> My ID is "main"!</ main >
18
18
< br />
19
19
< div >
20
- < label > Input:</ label > < input />
20
+ < label > Input:</ label > < input id =" input " />
21
21
</ div >
22
22
< br />
23
23
< div >
Original file line number Diff line number Diff line change
1
+ function addingEventListener ( ) {
2
+ }
You can’t perform that action at this time.
0 commit comments