10秒后显示div,10秒后隐藏
问题描述:
页面加载后,我需要在10秒内显示一个div(例如#mybox),再让它保持可见状态10秒钟,然后以不错的滑入/滑出效果进行隐藏.
I need to show a div (e.g. #mybox) in 10secs after page load, keep it visible for another 10 secs and then hide with a nice sliding in/out effects.
非常感谢任何提示/帮助!
Thanks a lot for any hints/helps!
答
请使用以下功能:
cycle();
function cycle() {
$('#myid')
.delay(10000)
.fadeIn(300)
.delay(10000)
.fadeOut(300, cycle);
}
如果我们不需要循环,那么只需要一行代码:
If we don't need a loop, then just one line of code is needed:
$('#myid').delay(10000).fadeIn(300).delay(10000).fadeOut(300);