Close Modal Box after 10 seconds
How can i close the jquery modal box a开发者_如何学运维fter 10 seconds ???
Use setTimeOut function.
//make sure you have lower case "o"
setTimeout(function(){
$(dialog).close();
}, 10000);
setTimeout(function() { // code to close the modal }, 10000);
The jQuery UI modal dialog will automatically open on page load if you declare no other parameters in its initialisation call:
$(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:
setTimeout($('#dialog').dialog('close'), 10000);
Use the setTimeout
function to delay an action by a number of milliseconds:
setTimeout(function(){
$('#dialogModal').modal('hide')
}, 10000);
where dialogModal
is the dialog's id attribute, and 10000
is a ten second delay in milliseconds.
You can execute any code in the function block.
Showing #ads modals on page load then close after 10 seconds :
<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 :)
精彩评论