我希望使用button : { }
向具有$('.ui-dialog-buttonpane button:eq(0)')
的元素生物添加类定义,而不执行 $(function() {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
//add a class definition to the delete all items button here. tried
//class:'save' didn't work
"Delete all items": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
{{1}}
答案 0 :(得分:2)
您可以使用option对象指定类名。
$("#dialog-confirm").dialog({
resizable: false,
height: 140,
modal: true,
buttons: {
//add a class definition here.
"Delete all items": {
'class': 'customClass', //<-- specify the class here
text: 'Delete all items', //<-- text for the button
click: function () { //click handler
$(this).dialog("close");
}
},
Cancel: function () {
$(this).dialog("close");
}
}
});
<强> Fiddle 强>