这是一个简单的练习,我想在其中隐藏我放在 Html 文件中的链接。但是在我的函数中的计时器用完后让它出现。
这是 javascript 位(下面是 html 位)
var i = 10;
var time;
var countdown = document.getElementById("countdown");
var link = document.getElementById("link");
function MyFunction3() {
document.getElementById("imageoef").style.visibility="visible";
link.style.visibility="hidden";
i--;
countdown.innerHTML= i;
time = setTimeout ("MyFunction3();",1000);
if (i < 1) {
countdown.innerHTML="";
document.getElementById("imageoef").style.visibility="hidden";
link.style.visibility="visible";
}
}
HTML
<img src="images/loading.gif" alt="Loading..." id="imageoef" style="visibility:hidden" />
<form method="post">
<input onclick="MyFunction3();" type="button" value="start download" />
</form>
<div id="countdown">
<a id="link" href="http://freelanceswitch.com/freelance-freedom/freelance-freedom-2/" >Your download is ready!</a>
</div>