我想使用jQuery的UI对话框进行确认:
$( "#dialog-confirm" ).dialog({
buttons: {
"Button One": function() {
$( this ).dialog( "close" );
},
"Button Two": function() {
$( this ).dialog( "close" );
}
}
});
});
但我想根据条件更改按钮标签:
if (status == "active") {
var b1 = "Red";
var b2 = "Green";
} else {
var b1 = "Green";
var b2 = "Red";
}
似乎无法将两者结合起来......
答案 0 :(得分:5)
通过提供新的按钮数组,您可以在jQuery UI Dialog创建后设置按钮。
如果您将status
变量更改为this demo中active
以外的任何变量,则可以看到按钮是使用不同的标签创建的。