我具有一个使确认框弹出的功能。如果按“确定”,则执行某项操作;如果按“取消”,则取消该功能。我有其他这样的功能很好。但是,对于此按钮,“取消”按钮可以正常工作,但是“确定”按钮不起作用。它只是关闭确认框,并且不执行其他任何操作。为什么会发生这种情况,我该如何解决?
function buySparkystal() {
var r = confirm("Are you sure you want to buy 1 sparkystal with 1 metal, 1 crystal and an anvil?");
if (r == true) {
if (metal >= 1 && crystal >= 1 && anvil == 1) {
crystal -= 1;
metal -= 1;
sparkystal += 1;
alert("Transaction completed. You now have " + sparkystal + " sparkystal.")
} else {
alert("Insufficient Funds. Transaction Cancelled.");
}
} else {
alert("Transaction cancelled.");
}
}
拼写错误...我真是个白痴。