javascript单击操作触发了两个操作 我有以下html: 2013年4月9日 发票#1365512756 270000卢比 确认付款
类标题栏绑定了一个javascript点击动作,类按钮也绑定了一个点击动作。问题是,当我单击按钮时,它也会触发标题栏单击操作。如何使单击不会传播?如果您使用jquery,可以这样做javascript单击操作触发了两个操作 我有以下html: 2013年4月9日 发票#1365512756 270000卢比 确认付款,javascript,Javascript,类标题栏绑定了一个javascript点击动作,类按钮也绑定了一个点击动作。问题是,当我单击按钮时,它也会触发标题栏单击操作。如何使单击不会传播?如果您使用jquery,可以这样做 I have the following html: <div class="title-block"> <span class="date">Apr 09, 2013</span> <span class="invoice">Invoice #136
I have the following html:
<div class="title-block">
<span class="date">Apr 09, 2013</span>
<span class="invoice">Invoice #1365512756</span>
<span class="retail-price">Rp 270000</span>
<span class="arvo-regular button green confirm-payment" data-id="2">Confirm Payment</span>
<img src="/bundles/shopiousmain/img/dashboard-li-down-arrow.png">
</div>
JS
您正在使用jQuery吗?如果是这样,您是否尝试过
e.stopPropagation()
?
$("#buttonClass").click(function(e) {
// mouse click on button
e.stopPropagation();
});
function doSomething (e) {
var event = e || window.event;
if (event.stopPropagation) {
event.stopPropagation();
} else {
event.cancelBubble = true;
}
}