gpt4 book ai didi

javascript - 隐藏下载链接 10 秒? js

转载 作者:行者123 更新时间:2023-11-30 13:35:05 25 4
gpt4 key购买 nike

嘿,我怎么能隐藏我的下载链接,并做一个倒计时类型的东西。也许让它从 10 开始倒计时,一旦完成就会出现下载链接,最好用 js 来做,对吗?

有人知道怎么做吗? :D

谢谢

最佳答案

完整示例:

<span id="countdown"></span>
<a id="download_link" href="download.zip" style="display:none;">Download</a>
<noscript>JavaScript needs to be enabled in order to be able to download.</noscript>
<script type="application/javascript">
(function(){
var message = "%d seconds before download link appears";
// seconds before download link becomes visible
var count = 10;
var countdown_element = document.getElementById("countdown");
var download_link = document.getElementById("download_link");
var timer = setInterval(function(){
// if countdown equals 0, the next condition will evaluate to false and the else-construct will be executed
if (count) {
// display text
countdown_element.innerHTML = "You have to wait %d seconds.".replace("%d", count);
// decrease counter
count--;
} else {
// stop timer
clearInterval(timer);
// hide countdown
countdown_element.style.display = "none";
// show download link
download_link.style.display = "";
}
}, 1000);
})();
</script>

关于javascript - 隐藏下载链接 10 秒? js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5206884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com