基于下面的代码展示一个JQuery对话框,按钮文本显示为字面上的“b”而不是变量b的值。
例如:showWarningDialog('myBody', 'myTitle', 'go')
显示一个标有 b
而不是 go
的按钮的对话框。
如何让 go
出现?
function showWarningDialog(theBody, theTitle, buttonText) {
var t = "Warning";
if (theTitle != null) {
t = theTitle;
}
var b = "Ok";
if (buttonText != null) {
b = buttonText;
}
$("#div-dialog-warning div").text(theBody);
$("#div-dialog-warning").dialog({
title: t,
resizable: false,
height: 160,
modal: true,
buttons: {
b : function () {
$(this).dialog("close");
}
}
});
}
buttonText
选项。根据文档,属性键是按钮的文本
。 - Matt Ball