[英]How to call inline onclick after external event - javascript/jquery?
基本上我有一個按鈕,如下所示:
<button onclick="productAddToCartForm.submit(this) " class="js-checkBackOrdered" type="button">Add to Cart</button>
我有這些JS代碼:
jQuery(".js-checkBackOrdered").click(function(){
if(jQuery("#backordered").length>0){
showpopup();
//should not execute the inline onclick here
}
});
jQuery("#confirmbtn").click(function(){
//execute the inline onclick event here
})
jQuery("#closebtn").click(function(){
closepopup();
//do not proceed with the inline onclick event
})
我遇到的問題是,每次單擊按鈕時,內聯onclick都會與外部事件同時觸發。
如何停止此操作並隨后執行productAddToCartForm.submit(this)
?
請幫忙。
基本上,您嘗試將多個處理程序綁定到一個事件。 您需要定義調用它們的順序。
你能行的
<button class="js-checkBackOrdered" type="button">Add to Cart</button>
jQuery(".js-checkBackOrdered").click(function(){
if(jQuery("#backordered").length>0){
showpopup();
}
productAddToCartForm();
});
function productAddToCartForm(){
//you code
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.