Jquery Dialog将自定义类添加到按钮

时间:2013-10-21 21:31:09

标签: jquery html dialog

我希望使用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" ); } } }); });

之类的操作

http://jsfiddle.net/3zcEY/

{{1}}

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