<div id="parent" class="parent-item" onClick="parentFunc()">
<div id="child" class="child-item" onClick="childFunc()">
</div>
</div>
.parent-item {
background-color: red;
width: 200px;
height: 200px;
display: flex;
justify-content: center;
align-items: center;
}
.child-item {
background-color: blue;
width: 50%;
height: 50%;
}
function parentFunc() {
alert("親のクリックイベント");
}
function childFunc() {
alert("子のクリックイベント");
return false;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.