File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1+ // currentTarget - always refers to the element
2+ // - to which the event handler has been attached to
3+ // target - identifies the element on which the
4+ // - event occured
5+
6+ const btns = document . querySelectorAll ( '.btn' ) ;
7+
8+ // forEach()
9+ btns . forEach ( function ( btn ) {
10+ btn . addEventListener ( 'click' , function ( e ) {
11+ // if click button will add color black for
12+ // all button element include h1 and strong element be black color
13+ e . currentTarget . style . color = 'black' ;
14+ console . log ( e . currentTarget ) ;
15+ // but if target, will effect on element yg di click
16+ // and not effect all element just element click will change
17+ // but if main click all element will change
18+ e . target . style . textTransform = 'lowercase' ;
19+ console . log ( e . target ) ;
20+ } ) ;
21+ } ) ;
You can’t perform that action at this time.
0 commit comments