我在下面有这个代码,当选择更改它工作得很好并检查正确的条件但是第二次如果我改变选择两个条件相继运行
$('#x_Statususer').on('change', function () {
var chng = !this.options[this.selectedIndex].defaultSelected;
if (chng) {
alert("has changed");
var celm=$( this ).val();
if (celm== "Revision") {
$("#btnAction").click(function() {
var r = confirm("Are you sure you want to set to Revision! ");
if (r == false) {
return false;
}
});
}
else if (celm == "Canceled") {
$("#btnAction").click(function() {
var r = confirm("Are you sure you want to set to Cancel! ");
if (r == false) {
return false;
}
});
}
} else {}
});
答案 0 :(得分:0)
问题是您在每次更改时将点击事件重新绑定到#btnAction
。尝试改变:
$("#btnAction").click(function() {...});
要:
$("#btnAction").one(function() {...});