使弹出窗口在 5 秒后淡入并在关闭时淡出

Make popup fade in after 5 seconds and fade out on close

这是我的代码:https://jsfiddle.net/hb4bb761/

当前弹出窗口立即出现。如何让它在 5 秒后出现以及如何让它在出现时淡入?

还有什么方法可以让它在关闭的时候消失?

这里是有问题的js:

$(function(){
$('#screen, #modal').show();
});

$('#screen, #modal button').click(function(){
$('#screen, #modal').hide();
});

jQuery已经提供了这样的功能,你可以直接使用fadeIn()fadeOut()

我在这里调整了你的fiddle

如果你想延迟执行你可以使用delay().

$('selector').delay(5000).fadeIn(1000)