- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path21_currentTarget_target.js
More file actions
Latest commit
21 lines (19 loc) · 762 Bytes
/
Copy path21_currentTarget_target.js
File metadata and controls
21 lines (19 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// currentTarget - always refers to the element
// - to which the event handler has been attached to
// target - identifies the element on which the
// - event occured
constbtns=document.querySelectorAll('.btn');
// forEach()
btns.forEach(function(btn){
btn.addEventListener('click',function(e){
// if click button will add color black for
// all button element include h1 and strong element be black color
e.currentTarget.style.color='black';
console.log(e.currentTarget);
// but if target, will effect on element yg di click
// and not effect all element just element click will change
// but if main click all element will change
e.target.style.textTransform='lowercase';
console.log(e.target);
});
});