Why two click handlers when you have them:
$( '.parent' ).click(function ( e ) { if ( $( e.target ).is( '.child' ) ) { alert( 'child click' ); } else { alert( 'parent click' ); } });
Live demo: http://jsfiddle.net/J3EAQ/2/
A generalization of this template:
$( element ).click(function ( e ) { if ( e.target === this ) {
Split handlers?
$( '.parent' ).click(function ( e ) { if ( this ==== e.target ) { parentClicked.call( e.target, e ); } else { childClicked.call( e.target, e ); } }); function childClicked( e ) {
Ε ime Vidas
source share