How can you avoid a child element that is absolutely positioned to trigger the parent click handler?
If I click the div
, it triggers clickMe()
.
<div onclick="clickMe()" style="height: 1600px; background: blue;">
<div> Test </div>
</div>
function clickMe() {
console.log("CLICK ME CLICKED")
}
Is the only way to prevent it by using a click handler on div
to stop propgation?
<div onclick="clickMe()" style="height: 1600px; background: blue;">
<div onclick="buttonClicked()"> Test </div>
</div>
function clickMe() {
console.log("CLICK ME CLICKED")
}
function buttonClicked() {
event.stopPropagation();
}