请告诉我如何在不执行go函数的情况下,在单击按钮时执行go2函数
function go($i) {
alert($i);
}
function go2($i) {
alert($i);
}div {
width: 200px;
height: 200px;
background: #eaeaea;
}<div onclick="go('159');">
<button onclick="go2('160');">Go 2</button>
</div>
发布于 2020-02-21 17:58:03
您需要使用event.stopPropagation()
function go($i) {
alert($i);
}
function go2($i) {
event.stopPropagation();
alert($i);
}div {
width: 200px;
height: 200px;
background: #eaeaea;
}<div onclick="go('159');">
<button onclick="go2('160');">Go 2</button>
</div>
https://stackoverflow.com/questions/60336109
复制相似问题