My code is
<div id="hello">
<div>A</div></div>
<script>
$(function(){
$(document).mousedown(function(event){alert(event.target.id);});
});</script>
Now when i click on div id “hello” it is alerting null as it is taking the id of center div but i want the id of outer div.How can this be achieved?
Because the target was the innermost div
try this instead: