I have a tree of divs:
-
You can add a handler for the child that will prevent the click event from propagating up:
function handler(event) {
event.stopPropagation();
// now do your stuff
}
$('#a').add('#b').click(handler);
This way clicks to '#b'
will not propagate to '#a'
. Neither will clicks to '#c'
go to '#b'
, and hence not to '#a'
.
- 热议问题