event.target과 event.currentTarget의 차이점에 대해 설명해주세요 #11
klmhyeonwoo
started this conversation in
General
Replies: 2 comments 2 replies
-
|
모르는 것 투성이!!! 두 속성의 핵심 차이는 **"이벤트가 발생한 지점인가, 아니면 이벤트 리스너가 달린 지점인가"**에 있습니다.
• event.target: 이벤트가 실제로 발생한 가장 안쪽의 요소 (클릭한 바로 그 놈)
① event.target (Origin) ② event.currentTarget (Owner) |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
event.target은 이벤트가 실제로 발생한 요소를 의미하고, function handleClick(event) {
console.log(event.currentTarget); // <div>
console.log(event.target); // <p>
}
<div onClick={handleClick}>
<p>Click me!</p>
</div> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
event.target과 event.currentTarget의 차이점에 대해 설명해주세요
@prgmr99, @klmhyeonwoo
Beta Was this translation helpful? Give feedback.
All reactions