For thie HTML:
<div id="a">
<div id="b">
</div>
</div>
when I click b, both of a and b‘s click even handler will be triggered. My problem is, how can these two event handler communicate? e.g.
$('#b').bind('click', handlerB);
$('#a').bind('click', handlerA);
is is possible for handlerA to access variables in handlerB, or handlerB can pass variables to handlerA through the event object or something?
That not only breaks the idea of event but also might not cover all your needs. E.g. you might need optionally prevent bubbling depending on some condition in *handler*B.
I suggest preventing the event bubbling from handlerB and call handlerA from handlerB explicitly.