javascript中的jquery-ui对话框窗口:
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
"Ok": function() {
$( this ).dialog( "close" );
},
"Cancel": function() {
$( this ).dialog( "close" );
}
}
});
Run Code Online (Sandbox Code Playgroud)
有两个按钮"Ok"和"Cancel".每个按钮都有功能.按钮名称几乎没有固定.有一些方法可以从变量中命名按钮吗?像这样:
var Button1 = "Ok";
var Button2 = "Cancel";
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
Button1: function() {
$( this ).dialog( "close" );
},
Button2: function() {
$( this ).dialog( "close" );
}
}
});
Run Code Online (Sandbox Code Playgroud)
我尝试上面的代码,但按钮出现名称"Button1"和"Button2".我还可以在按钮中显示图像但不能显示文本吗?