jQuery jquery对话框替换关闭按钮图标

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13162480/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 12:21:29  来源:igfitidea点击:

jquery dialog replace close button icon

jquerycssjquery-uibuttonjquery-ui-dialog

提问by Bruno Mósca

I want change the default close icon button in jquery Dialog.

我想更改 jquery 对话框中的默认关闭图标按钮。

I tried to add this css class in jquery-ui-1.8.23.custom.css:

我试图在 jquery-ui-1.8.23.custom.css 中添加这个 css 类:

.ui-icon-myCloseButton { background-image: url(/path/image.png); }

and in the Dialog Definitions:

并在对话框定义中:

$('#documentsDialog').dialog({
   create: function(event,ui) {
           var widget = $(this).dialog("widget");
           $(".ui-dialog-titlebar-close span",widget).removeClass("ui-icon-closethick").addClass(".ui-icon-myCloseButton");

});

but no luck, any idea?

但没有运气,知道吗?

回答by Adriano Carneiro

You were just missing a closing curly bracket:

您只是缺少一个右大括号:

$('#documentsDialog').dialog({
    create: function(event, ui) {
        var widget = $(this).dialog("widget");
        $(".ui-dialog-titlebar-close span", widget).removeClass("ui-icon-closethick").addClass("ui-icon-myCloseButton");
    }
});?

But, most important, your css class should be declared as:

但是,最重要的是,您的 css 类应声明为:

.ui-icon.ui-icon-myCloseButton{
    background-image: url(https://www.goldbroker.com/pages/images/close.png);
}?

The thing is that the definition at .ui-icon was overriding your custom image. When you redefine using the css above, it fully works.

问题是 .ui-icon 的定义覆盖了您的自定义图像。当您使用上面的 css 重新定义时,它完全有效。

Here, have a fiddle: http://jsfiddle.net/adrianonantua/FuWsK/2/

在这里,有一个小提琴:http: //jsfiddle.net/adrianonantua/FuWsK/2/