Wasim Shaikh
Wasim Shaikh

Reputation: 7030

Popup Dialog Hide after 10sec

I am working on some website , i have used jQuery UI , for pop-up dialog .

I want to close that after 10sec, I have used fadOut 10000 ms but its slowly fades.

Here is the link

View the source code and please help me in this.

Upvotes: 1

Views: 1812

Answers (2)

Keith
Keith

Reputation: 155722

There is a javascript function that allows you to carry out an action after a timeout:

setTimeout('$("#dialog").hide()', 10000);

Usually you're better off passing a function rather than the text to eval()

setTimeout(hideDialog, 10000);

function hideDialog() { $('#dialog').hide(); }

Or, if you want just one line:

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

Upvotes: 4

peirix
peirix

Reputation: 37761

Keith's version is a good approach, another, maybe more hacky way, of doing it is this:

$("#modal").animate({opacity:1}, 10000, function() {
    $(this).fadeOut();
});

This way, you can link up everything that needs to be done to the modal in one line...

Upvotes: 5

Related Questions