在一段时间后出现代码以使div出现 [英] Code to make div appear after a certain amount of time
问题描述
我正在寻找让网站在一定时间后出现div的代码。这是我谈论的事情:
I'm looking for code that makes a div appear after a certain amount of time on a site. Here's the sort of thing I'm talking about:
<div class="container">
<div class="secretpopout">
This is the div I want to pop out after a couple of minutes.
</div>
</div>
我对JavaScript和jQuery比较陌生,但我假设我需要使用setTimeout或类似的东西。我试过在网上找到答案,但是如果有人能够用某种方式解释它,设计师(而不是程序员)会得到它,那将是非常棒的 - 任何轻巧的东西都会非常感谢。
I'm relatively new to javascript and jQuery, but I'm assuming I will need to use the setTimeout or something similar. I've tried finding the answer online, but if someone could explain it in a way a designer (as opposed to a programmer) would get it, that would be great - ANY LIGHT shed on this would be greatly appreciated.
谢谢。
推荐答案
+使用 .delay()
,像这样:
You can do this with very little code in jQuery 1.4+ using .delay()
, like this:
$(function() {
$(".secretpopout").delay(120000).fadeIn();
});
这会在2分钟后显示出来,只给它一些CSS,以便最初隐藏:
This would show it after 2 minutes, just give it some CSS so it's hidden initially:
.secretpopout { display: none; }
这篇关于在一段时间后出现代码以使div出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!