javascript - 向一些 javascript 按钮添加一个类

标签 javascript jquery css class button

<分区>

我正在尝试对用 javascript 编写的表单进行一些编辑,但我真的只是刚刚熟悉这种语言。我正在尝试格式化几个按钮;为此,我想为它们添加一个类。有问题的按钮是“添加”和“取消”,它们使用以下函数呈现:

    showAddDialog: function() {
        $("#dialog").data("product",upsmart.products.pcounter);
        $("#dialog").html(upsmart.products.createForm(upsmart.products.pcounter));
        $("#photo_button").click(open_media_library);
        upsmart.products.pcounter++;
        $("#dialog").dialog({
            width: 600,
            modal: true,
            buttons: {
                "Add": upsmart.products.addProduct,
                "Cancel": function() {
                    $(this).dialog("close");
                }
            }
        });
    },

我怎样才能做到这一点?

感谢您的帮助。

最佳答案

试试这个:

$("#dialog").dialog({
            width: 600,
            modal: true,
            buttons: [
        {
            text: "Cancel",
            "class": 'cancelButtonClass',
            click: function() {
                // Cancel code here
            }
        },
        {
            text: "Save",
            "class": 'saveButtonClass',
            click: function() {
                // Save code here
            }
        }
    ],
    close: function() {
        // Close code here (incidentally, same as Cancel code)
    }
});

来源:Apply CSS to jQuery Dialog Buttons

关于javascript - 向一些 javascript 按钮添加一个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18518764/

上一篇:div 中的 CSS 背景图片

下一篇:jquery - 无法让导航菜单呈现在 div 内部

相关文章:

javascript - jQuery toggleClass 有效,在点击时添加 .text() 替换会破坏它

对象属性的 javascript 字符集

javascript - 尝试使用nodejsexpress打开网页时出错

javascript - 在 Angular 中覆盖 Controller

php - php变量后无法在html链接中使用类关键字

html - 用于在另一个元素之后或之前的元素的 CSS,未嵌套

javascript - then() 在 Promise 之前完成

javascript - 相对于另一个分区的 Bootstrap 列高度

javascript - 为什么 jQuery 下拉菜单需要点击两次?

javascript - 使用数据变量重新排列 div