页面加载2秒后显示div [英] Show div after 2 seconds of page load
本文介绍了页面加载2秒后显示div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在尝试在加载页面2秒后显示div。我可以通过在页面加载后两秒隐藏div来成功地执行相反的操作。问题是没有任何事情发生,div保持隐藏。如何在页面加载两秒后正确显示div?额外:表示两秒钟正在运行时表示ajax加载gif然后淡入div
I am currently trying to show a div 2 seconds after the page is loaded. I can successfully do the reverse by hiding the div two seconds after the page loads. The issue is that nothing occurs and the div stays hidden. How can I properly show a div after two seconds of page load? Extra: mean while the two seconds are running show an ajax loading gif and then fade in the div
<script type = "text/javascript">
$(window).load(function() {
setTimeout(function() {
$("#contentPost").show('fadeIn', {}, 500)
}, 2000);
});
</script>
html / css
<style>
.contentPost { display:none;}
</style>
<div class="contentPost">
<h2>Hi there</h2>
</div>
推荐答案
$(document).ready(function() {
$(".contentPost").delay(2000).fadeIn(500);
});
将完美运作。
这篇关于页面加载2秒后显示div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文