2012-04-16 85 views

回答

16

你應該使用setTimeout

open: function(event, ui) { 
    setTimeout(function(){ 
     $('#dialog').dialog('close');     
    }, 3000); 
} 

這裏的小提琴:http://jsfiddle.net/WrdM9/2/

+0

太棒了,謝謝! – 2012-04-16 18:48:42

2

使用jQuery的延時功能例如

$("#your-modal-id").slideDown(300).delay(800).slideUp(400); 
1

如果你也想加入一些轉變,我不會建議jQuery的效果基本show和動畫了slideDown。這些是緩慢的,因爲它使用CPU而不是GPU和動畫本身並不完全感覺正確

我會推薦Velocity.js來代替。請記住還要添加Velocity UI js。你可以做這樣的事情:

$("#your-modal-id").velocity('transition.slideUpBigOut', { delay: 3000 })