SO - 17342264

by Arun P Johny

HTML

<div id="a">
    a
    <div id="b">b</div> 
</div>

CSS

#a {background-color:blue;width:100px;height:200px;}
#b {background-color:red;margin-left:25px;width:50px;height:100px;}

JavaScript

document.getElementById("a").addEventListener('click', function() {
    console.log("A is clicked");
}, true)
document.getElementById("b").addEventListener('click', function() {
    console.log("B is clicked");
}, true)
document.addEventListener('click', function() {
    console.log("Document is clicked");
}, true)