That's because jQuerys' .on()
function passes the element who the event was fired from as this
, not the event itself.
If you try to do the following:
$('a').on('click', function () {
console.log(this);
});
You will see in your console the <a>
tag that got clicked on. This is applicable to both the DOM click
event as well as jQuery's. You can also see this <a>
tag from event.target
.*
If you want information about the event, then you need to inject it into your function as you've done so in your question:
$('a').on('click', function (event) {
console.log(event);
});
This way, all of your event information is found in event
. Likewise, it is only logical that you would stop propagating the event itself, as the element isn't propagating anywhere.