为 jquery 对话框按钮添加样式

0 javascript jquery jquery-ui

如何为对话框上的 jquery 按钮添加样式?我想给一些颜色上色,给其他颜色上色。

我试过使用这个类:但我似乎没有得到太大的效果。难道我做错了什么?我需要使用其他东西吗?我需要在别的地方放东西吗?

代码:

function DisplayCommonDialog(url, title, height, width) {
    HideDialogs();
    var dialogButtons = [{
        text: "Save",
        click: function () {
                    ...
                }
            }
        },
        width: '70px'
    }, {
        text: "Cancel",
        click: function () {
            $(this).dialog("close");
        }
    }];
    if (title.indexOf("Delete") >= 0) {
        dialogButtons = [{
            text: "OK",
            click: function () {
                ...
            },
            width: '70px'
        }, {
            text: "Cancel",
            click: function () {
                $(this).dialog("close");
            }
        }];
    }
if (popUpDialog != null) {
        $("#").dialog("option", {
            width: width,
            height: height,
            title: title,
            open: function () {
                ...
            },
            close: function () {
                ...
            },
            buttons: dialogButtons

        });
        ...
    }
    else {
        popUpDialog = $("#").dialog({
            width: width,
            height: height,
            autoResize: true,
            modal: true,
            title: title,
            open: function () {
                ...
            },
            close: function () { 
                ...
            },
            overlay:
            {
                opacity: 0.5,
                background: "black"
            },
            position: ['center', 'center'],
            buttons: dialogButtons
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

Mor*_*hak 5

要在对话框按钮中添加 css 类,只需使用按钮按钮属性“class”:

$("#").dialog({
    buttons: [{
        "text":'your button name',
        "click": $.noop,
        "class": 'your-css-class1 your-css-class2'
    }]
})
Run Code Online (Sandbox Code Playgroud)

创建对话框时将插入每个声明按钮中的属性“类”。

希望这有帮助。

此处提供有关对话框中按钮样式的类似问题