Javascript 单击确认框上的取消不会取消操作
HTML:Javascript 单击确认框上的取消不会取消操作,javascript,object,confirm,Javascript,Object,Confirm,HTML: 您好,我在我的网站上使用了上述功能,因此它会在每个红色背景的按钮上添加一个确认框。。现在,这似乎在起作用,每当我单击红色按钮时,就会弹出一个确认框,但是,如果我单击确认框上的取消,它不会取消操作。。这让我烦了好几个小时了。。我尝试了很多调试,但似乎找不到。有人能帮忙吗?好吧,你从确认方法返回,但在你调用它的地方你什么也不做 var Main={ addConfirmations:函数{ var e=document.queryselectoral.bg-red; 对于var t=0
您好,我在我的网站上使用了上述功能,因此它会在每个红色背景的按钮上添加一个确认框。。现在,这似乎在起作用,每当我单击红色按钮时,就会弹出一个确认框,但是,如果我单击确认框上的取消,它不会取消操作。。这让我烦了好几个小时了。。我尝试了很多调试,但似乎找不到。有人能帮忙吗?好吧,你从确认方法返回,但在你调用它的地方你什么也不做 var Main={ addConfirmations:函数{ var e=document.queryselectoral.bg-red; 对于var t=0;t
var Main = {
addConfirmations: function() {
var e = document.querySelectorAll(".bg-red");
for (var t = 0; t < e.length; t++) {
e[t].addEventListener("click", function() {
var e = this.getAttribute("title");
Main.confirmation(e)
})
}
},
confirmation: function(e) {
if (e === null || e.toString().length === 0) {
e = "Are you sure you want to proceed?"
}
return window.confirm(e);
}
}
window.onload = Main.addConfirmations
<input type="submit" class="bg-red" value="Delete">