SO Answer / Parent-child event

See: http://stackoverflow.com/questions/11153279/parent-child-event/

by KooiInc MeHere

HTML

<div id="p">
     div#p
     <div id="c">
         div#c
     </div>
    <div id="report"></div>
</div>

CSS

body {font: normal 0.8em verdana,arial;margin:1em;}
#report {width:30%; border-top: 1px solid #999;margin-top:1em;}
#report:before {content:'click results: '}

JavaScript

//one handler fits all

$("#p").on('click dblclick',function (e) {
    var originator = (e.target || e.srcElement).id, repx =  $('#report');
    if (/^c$/i.test(originator) && /dblclick/i.test(e.type)){return true;}
    
    if ($('#report br').length>=10){
        repx.fadeOut(function(){$(this).empty().show();});
    }
    
    repx.append('<br>div#'+originator+' '+
                    (/dblclick/i.test(e.type) ? 'double ' : "") + 
                    'click!'
               );
    return true;
});