내가 DIV ID를 클릭하면 내 코드event.target이 원하는 출력
<div id="hello">
<div>A</div></div>
<script>
$(function(){
$(document).mousedown(function(event){alert(event.target.id);});
});</script>
지금은 센터 DIV의 ID를 취하고로 "안녕하세요"가 null의 경고입니다하지만 난 외부의 ID를 원하는 div. 어떻게 달성 될 수 있습니까? 사용 event.target.parentNode.id
'A'를 클릭하면 부모의 ID가 출력되는 이유는 무엇이라고 생각하십니까? 또는 다른 곳을 클릭하면 # hello의 ID가 출력됩니까? – gabitzish
이벤트 캡처 및 버블 링. http://www.quirksmode.org/js/events_order.html – mossimokim