I'm very new to jquery and I'm currently reading "learning jQuery" I have a question regarding event capturing and event.target.
I have the html code like this:
<div id="switcher" class="switcher">
<h3>Style Switcher</h3>
<button id="switcher-default">
Default
</button>
<button id="switcher-narrow">
Narrow Column
</button>
<button id="switcher-large">
Large Print
</button>
</div>
According to event capturing with jQuery jQuery doesn't support event capturing and only support bubbling. Which means, if both buttons and div element are binded to the click event and when I click on the button, button's click will call first, then the div, and since event capturing is not supported, which means if I click on the div area, button's click function will NOT be called.
However, if I add something like this:
$("#switcher").click(function(event) {
alert(event.target);
});
and if I click on the button, the event target will be the button. If the selector $("#switcher") only select the div element, then how come when I click on the button, it alerts the event.target? I thought when I click on the button, the above jQuery will not be called at all?