Javascript 模式框在运行时更改标题和按钮名称
我希望能够在运行时更改模式的标题和按钮。 现在我有这个 我有赞成或反对的行动Javascript 模式框在运行时更改标题和按钮名称,javascript,jquery,jquery-ui,modal-dialog,jquery-dialog,Javascript,Jquery,Jquery Ui,Modal Dialog,Jquery Dialog,我希望能够在运行时更改模式的标题和按钮。 现在我有这个 我有赞成或反对的行动 var recButton = actions =='approval' ? 'Approve' : 'Deny'; $("#dialog").dialog( { modal : true, buttons : { 'update all' : function() { // window.location.reload(
var recButton = actions =='approval' ? 'Approve' : 'Deny';
$("#dialog").dialog(
{
modal : true,
buttons : {
'update all' : function() {
// window.location.reload();
// $( this ).dialog( "close" );
//do something here
},
Cancel : function() {
$(this).dialog("close");
}
}
}); //dialog
});
我也试着为巴顿做这件事
$("#dialog").dialog(
{
modal : true,
buttons : {
recButton : function() { ...
但在模态中,它并没有很好地转换,只是说recButton而不是变量值。我也需要改变标题
更新:通过简单的标题获得标题:嘿,Autolycus:试试这个男人:工作演示 请使用firebug检查元素id/类别:
$('.ui对话框标题').html(“绿巨人太棒了”)代码>应该可以做到这一点
希望对您有所帮助。:)
代码
$(document).ready(function() {
$('#theLink').click(function(){
$( "#forgot-dialog" ).dialog( "open" );
});
$( "#forgot-dialog" ).dialog({
modal: true,
autoOpen: false,
height: 255,
width: 300,
buttons: {
"ChangeTitle": function() {
alert("Title before cahnge ==> " + $('.ui-dialog-title').html());
$('.ui-dialog-title').html("HULK is awesome");
// document.forms["forgotform"].submit();
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
});
});
或
var formname = "form_name_here";
$("#ui-dialog-title-"+formname).innerHTML = "Hulk is awesome title";
下面的图片显示之前和之后
单击更改标题按钮前的图像
单击更改标题后
$(document).ready(function() {
$('#theLink').click(function(){
$( "#forgot-dialog" ).dialog( "open" );
});
$( "#forgot-dialog" ).dialog({
modal: true,
autoOpen: false,
height: 255,
width: 300,
buttons: {
"ChangeTitle": function() {
alert("Title before cahnge ==> " + $('.ui-dialog-title').html());
$('.ui-dialog-title').html("HULK is awesome");
// document.forms["forgotform"].submit();
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
});
});
嘿,奥托吕科斯:试试这个男人:工作演示
请使用firebug检查元素id/类别:
$('.ui对话框标题').html(“绿巨人太棒了”)代码>应该可以做到这一点
希望对您有所帮助。:)
代码
$(document).ready(function() {
$('#theLink').click(function(){
$( "#forgot-dialog" ).dialog( "open" );
});
$( "#forgot-dialog" ).dialog({
modal: true,
autoOpen: false,
height: 255,
width: 300,
buttons: {
"ChangeTitle": function() {
alert("Title before cahnge ==> " + $('.ui-dialog-title').html());
$('.ui-dialog-title').html("HULK is awesome");
// document.forms["forgotform"].submit();
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
});
});
或
var formname = "form_name_here";
$("#ui-dialog-title-"+formname).innerHTML = "Hulk is awesome title";
下面的图片显示之前和之后
单击更改标题按钮前的图像
单击更改标题后
$(document).ready(function() {
$('#theLink').click(function(){
$( "#forgot-dialog" ).dialog( "open" );
});
$( "#forgot-dialog" ).dialog({
modal: true,
autoOpen: false,
height: 255,
width: 300,
buttons: {
"ChangeTitle": function() {
alert("Title before cahnge ==> " + $('.ui-dialog-title').html());
$('.ui-dialog-title').html("HULK is awesome");
// document.forms["forgotform"].submit();
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
});
});
你总是用这种方式缩进代码吗?是的。这不好吗?我有很多代码,你总是用那种方式缩进代码吗?是的,不好吗?我有很多代码,我已经更改了标题,并在你发布此答案之前更新了票证。我希望按钮文本动态更改Hiya@Autolycus这样的东西试试这个bruv:当你点击按钮changetitle
时,它会同时更改按钮的标题和文本,这应该会有所帮助<代码>:)
在您发布此答案之前,我已经更改了标题并更新了票证。我希望按钮文本动态更改Hiya@Autolycus这样的东西试试这个bruv:当你点击按钮changetitle
时,它会同时更改按钮的标题和文本,这应该会有所帮助<代码>:)