Jquery对话框在一定时间后显示关闭按钮



经过一定时间后如何显示关闭按钮,我尝试了设置超时,但它不起作用。 有人可以提供基本示例以在一定时间后显示关闭按钮。

谢谢

编辑:
这就是我做自定义按钮的方式,因为有人问我这个问题

 var myButtons = {
                'Close': function () {
             },
             'Do not show this again': function () {
                    $.ajax({
                        type: "POST",
                        url: pagename,
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (response) {
                            if (response.d == true) {
                            }
                        }
                    });
                }
             };
$("#div").html("").dialog({ modal: true, resizable: false, width: 830, height: 580, show: 'slow', title: '', open: function (event, ui) { $(".ui-dialog-titlebar", $("#div").parent()).hide(); }, buttons: myButtons });

这就是我制作自定义按钮的方式。 我之所以有 MyButtons 变量,是因为我使用条件语句,并基于此在对话框打开时显示不同的按钮。

尝试如下操作,

演示

var $dialog = $('Your Dialog Div'); // Your Dialog Div
//Get Dialogs Parent and find the close button. 
//jQuery assigns .ui-dialog-titlebar-close class to the close X (a tag)
var $dialogCloseBtn = $dialog.parent().find('.ui-dialog-titlebar-close'); 
//hide the close button
$dialogCloseBtn.hide();
//show the close button after 10 seconds
setTimeout(function () {
    $dialogCloseBtn.fadeIn(100);
}, 10000);

假设:上面的代码假设你想隐藏/显示你在对话框标题中看到的jQuery默认关闭按钮。

如果对话框有一个带有id=close_dialog_button的关闭按钮,请为其提供display:none样式,然后使用以下代码:

$( "#dialog_div" ).dialog({
   open: function(event, ui) {
    setInterval(function() {
        $("#close_dialog_button").show();
    }, 10000);
 }
});

最新更新