I have this HTML:
<a href="#" class="action" data-action="foo">
<h1>Some</h1>
<p>Text<p>
</a>
and this binding:
$(document).on("click", ".action", function (e) {
var do = e.target.getAttribute("data-action");
if (do === undefined || do === null) {
console.log("error");
}
});
Strangely if I click on h1
or p
, my error logs, while I was expecting the click to bubble up to the link element.
Question:
What is the normal behaviour if elements nested inside an element with a click handler are clicked? Why is my click not bubbling up?
Thanks!