File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
2-ui/2-events/02-bubbling-and-capturing Expand file tree Collapse file tree 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.
55This handler is assigned to ` <div> ` , but also runs if you click any nested tag like ` <em> ` or ` <code> ` :
66
77``` html autorun height=60
8- <div onclick =" alert('The handler !')" >
8+ <div onclick =" alert('The handler!')" >
99 <em >If you click on <code >EM</code >, the handler on <code >DIV</code > runs.</em >
1010</div >
1111```
Original file line number Diff line number Diff line change 22form . onclick = function ( event ) {
33 event . target . style . backgroundColor = 'yellow' ;
44
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 ) ;
810} ;
You can’t perform that action at this time.
0 commit comments