JQuery UI – 更改按钮类

对于标准的JQuery UI对话框小部件,有人可以解释如何更改按钮上的CSS类吗? 我的addClass()调用不起作用。

$("#dialog-message").dialog({ modal: true, buttons: { Ok: function () { $(this).dialog("close"); $(this).addClass("btn"); } } }); 

要回答你的意思,“有人可以解释我如何更改标准JQuery UI对话框小部件按钮的CSS类”,有几种方法。 这是最独立的。 请注意, 'class'用单引号封装。 这是因为IE不会中断。

 $("#dialog-message").dialog({ modal: true, buttons:[ { text: 'Ok', 'class': 'btn', click: function(){ $(this).dialog("close"); } }, { text: 'Cancel', 'class': 'cancel', click: function(){ $(this).dialog("close"); } }, ] }); 

dialogClass似乎就是你要找的东西

 $("#dialog-message").dialog({ modal: true, dialogClass: 'btn', ... });