我想在jQuery对话框的按钮之间添加一些自定义HTML(特别是包含单词“or”的跨度)。
我有的Javascript是这样的:
$("#foo").dialog({
autoOpen: false,
width: 600,
modal: true,
resizable: false,
buttons: {
save: { text: 'Save', class: 'form-finish form-submit', click: function() {
…
}
},
cancel: { text: 'Cancel', class: 'form-cancel', click: function() {
$( this ).dialog( "close" );
}
}
}
});
它产生的HTML是:
<button class="form-finish form-submit ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false"><span class="ui-button-text">Save</span></button>
<button class="close cancel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false"><span class="ui-button-text">Cancel</span></button>
我想要的是:
<button class="form-finish form-submit ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false"><span class="ui-button-text">Save</span></button>
<span class="article">or</span>
<button class="close cancel ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" role="button" aria-disabled="false"><span class="ui-button-text">Cancel</span></button>
有没有办法在不破解jQuery UI的核心的情况下做到这一点?谢谢!
答案 0 :(得分:3)
创建对话后执行类似的操作?
$(".form-finish").after("<span class='article'>or</span>");