10秒钟后关闭模态框

时间:2021-11-04 11:58:36

How can i close the jquery modal box after 10 seconds ???

怎么能在10秒后关闭jquery模态框???

5 个解决方案

#1


22  

Use setTimeOut function.

使用setTimeOut函数。

//make sure you have lower case "o"
setTimeout(function(){
    $(dialog).close();
}, 10000);

#2


5  

setTimeout(function()
{

   // code to close the modal

}, 10000);

#3


3  

The jQuery UI modal dialog will automatically open on page load if you declare no other parameters in its initialisation call:

如果在初始化调用中没有声明其他参数,则jQuery UI模式对话框将在页面加载时自动打开:

$(function() {
$( "#dialog" ).dialog();
});

To have the dialog close after a delay you should be able to include a call further down your DOM ready event:

要在延迟后关闭对话框,您应该能够在DOM ready事件中进一步调用:

setTimeout($('#dialog').dialog('close'), 10000);

#4


0  

Use the setTimeout function to delay an action by a number of milliseconds:

使用setTimeout函数将操作延迟几毫秒:

setTimeout(function(){
    $('#dialogModal').modal('hide')
}, 10000);

where dialogModal is the dialog's id attribute, and 10000 is a ten second delay in milliseconds.

其中dialogModal是对话框的id属性,10000是十秒延迟(以毫秒为单位)。

You can execute any code in the function block.

您可以在功能块中执行任何代码。

#5


0  

Showing #ads modals on page load then close after 10 seconds :

在页面加载时显示#ads模态,然后在10秒后关闭:

    <script>
    $(window).load(function()
    {
    $('#ads').modal('show');});

    $(window).load(function()
    {
    setTimeout(function(){
    $('#ads').modal('hide')
    }, 10000);});
    </script>

This code working for me after trying all the other way closing modals :)

尝试所有其他方式关闭模式后,此代码为我工作:)

#1


22  

Use setTimeOut function.

使用setTimeOut函数。

//make sure you have lower case "o"
setTimeout(function(){
    $(dialog).close();
}, 10000);

#2


5  

setTimeout(function()
{

   // code to close the modal

}, 10000);

#3


3  

The jQuery UI modal dialog will automatically open on page load if you declare no other parameters in its initialisation call:

如果在初始化调用中没有声明其他参数,则jQuery UI模式对话框将在页面加载时自动打开:

$(function() {
$( "#dialog" ).dialog();
});

To have the dialog close after a delay you should be able to include a call further down your DOM ready event:

要在延迟后关闭对话框,您应该能够在DOM ready事件中进一步调用:

setTimeout($('#dialog').dialog('close'), 10000);

#4


0  

Use the setTimeout function to delay an action by a number of milliseconds:

使用setTimeout函数将操作延迟几毫秒:

setTimeout(function(){
    $('#dialogModal').modal('hide')
}, 10000);

where dialogModal is the dialog's id attribute, and 10000 is a ten second delay in milliseconds.

其中dialogModal是对话框的id属性,10000是十秒延迟(以毫秒为单位)。

You can execute any code in the function block.

您可以在功能块中执行任何代码。

#5


0  

Showing #ads modals on page load then close after 10 seconds :

在页面加载时显示#ads模态,然后在10秒后关闭:

    <script>
    $(window).load(function()
    {
    $('#ads').modal('show');});

    $(window).load(function()
    {
    setTimeout(function(){
    $('#ads').modal('hide')
    }, 10000);});
    </script>

This code working for me after trying all the other way closing modals :)

尝试所有其他方式关闭模式后,此代码为我工作:)