我有以下标记:
<div class="parent">
I should change my color to green when clicked
<div class="element">I should do nothing when clicked</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是相关的CSS:
.parent {
width:200px;
height:200px;
background: red;
color: #fff;
}
.parent:active {
background:green;
}
.element {
background:blue;
}
Run Code Online (Sandbox Code Playgroud)
有什么办法来防止触发.parent的:active伪类时,.element点击是什么吗?点击没有运气e.stopPropogation()时尝试.element.
演示