如何将取消按钮的文本从CANCEL更改为CLOSE?谢谢!
$("#dialog").dialog({
buttons : [
{
text : 'SAVE',
click : function() {}
},
{
text : 'CANCEL',
click : function() {}
}
]
});
$("#button").click(function(){alert('Please change cancel button text from "CANCEL" to "CLOSE"');});
<div id="dialog"><button id="button">Change cancel button text from "CANCEL" to "CLOSE"</button></div>
答案 0 :(得分:12)
为对话框指定类名,然后从类中选择UI按钮。
$('#foo').dialog({
buttons: {
CANCEL: function() {
alert(1);
}
},
dialogClass: 'my-dialog'
});
$('.my-dialog .ui-button-text:contains(CANCEL)').text('CLOSE');
答案 1 :(得分:9)
这是一件非常简单的事情:)
$( "#dialog" ).dialog( {
"buttons" : [
{
id: "my-button",
text: "My button",
click:function() {
$("#my-button span").text( "Our button!:)" );
}
} ]
} );
答案 2 :(得分:3)
您可以在初始化(documentation)之外设置按钮的文本:
$( "#dialog" ).dialog({
autoOpen: true,
buttons: [{
text: "Cancel",
click: function() {
$( this ).dialog( "close" );
}
}]
});
$( "#dialog" ).dialog( "option", "buttons", [ { text: "Close", click: function() { $( this ).dialog( "close" ); } } ] );
您也可以将其绑定到活动。