File tree 2 files changed +6
-4
lines changed
2-ui/2-events/02-bubbling-and-capturing
2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ Let's start with an example.
5
5
This handler is assigned to ` <div> ` , but also runs if you click any nested tag like ` <em> ` or ` <code> ` :
6
6
7
7
``` html autorun height=60
8
- <div onclick =" alert('The handler !')" >
8
+ <div onclick =" alert('The handler!')" >
9
9
<em >If you click on <code >EM</code >, the handler on <code >DIV</code > runs.</em >
10
10
</div >
11
11
```
Original file line number Diff line number Diff line change 2
2
form . onclick = function ( event ) {
3
3
event . target . style . backgroundColor = 'yellow' ;
4
4
5
- alert ( "target = " + event . target . tagName + ", this=" + this . tagName ) ;
6
-
7
- event . target . style . backgroundColor = '' ;
5
+ // chrome needs some time to paint yellow
6
+ setTimeout ( ( ) => {
7
+ alert ( "target = " + event . target . tagName + ", this=" + this . tagName ) ;
8
+ event . target . style . backgroundColor = ''
9
+ } , 0 ) ;
8
10
} ;
You can’t perform that action at this time.
0 commit comments