我有一个应用程序,当你点击背景时会发生某些事情,但是,如果你点击在背景上方的其他东西,我不希望它激活。例如:
function handleClick() {
alert("Hello!");
}
.container {
position: absolute;
height: 100%;
width: 100%;
background: red;
}
.button {
position: absolute;
height: 20%;
width: 20%;
background: green;
}
<div class="container" onClick="handleClick()">
<div class="button"></div>
</div>