简体   繁体   English

我如何摆脱jQuery模式对话框上的关闭按钮

[英]how can i get rid of the close button on a jquery modal dialog box

I want to have a jquery modal dialog that will have one button that will say "yes" and close the dialog. 我想要一个jquery模态对话框,它将有一个按钮,显示“是”并关闭对话框。 Is there any way to hide/turn off the default "Close" button or should I use another jquery element like a pop up panel? 有什么方法可以隐藏/关闭默认的“关闭”按钮,还是应该使用其他jquery元素(如弹出面板)? This code adds the yes button but does not turn off the close button: 这段代码添加了是按钮,但没有关闭关闭按钮:

$(document).ready(function(){
    $("#dialog-message").dialog({
        modal:true,
        buttons: {
        "Yes": function() {
          $( this ).dialog( "close" );
        },
    }
    });

});

You can hide it using CSS: 您可以使用CSS隐藏它:

.ui-dialog-titlebar-close { display: none;}

or you can init the dialog like this: 或者您可以这样初始化对话框:

$("#dialog-message").dialog({
    modal:true,
    buttons: {
        "Yes": function() {
            $( this ).dialog( "close" );
        }
    }
}).dialog("widget").find(".ui-dialog-titlebar-close").hide(); // find and hide the button right after creating the modal

Also, IE doesn't like the comma after the last property of an object so remove it. 另外,IE不喜欢对象的最后一个属性后的逗号,因此请将其删除。

Add a CSS rule: 添加CSS规则:

.ui-dialog-titlebar-close {
    display:none;
}

jsFiddle example jsFiddle示例

CSS CSS

.ui-dialog-titlebar-close { display: none;}

jQuery: jQuery的:

$(".ui-dialog-titlebar-close").remove();

Just whatever you have to do to grab the item with the class "ui-dialog-titlebar-close" 只需执行“ ui-dialog-titlebar-close”类即可获取该项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM