그 외 잡다구리
이벤트 함수에서 target vs currentTarget
kwangsunny
2021. 7. 3. 00:10
target : 이벤트가 생성된 위치의 element
currentTarget : 생성된 이벤트가 퍼지면서 발생된 현재위치의 element
ex)
<div onclick="test" style="width:100px; height:100px;">
<a id="btn">[요기]</a>
</div>
에서 [요기] 를 클릭하면
function test( e ) { } 에서
e.target == <a>
e.currentTarget == <div> 가 된다.