我有这个JavaScript的功能,倒计时直到你可以点击下载按钮,但是我想它一旦点击它,要么再次禁用或开始倒计时,最好是禁用。重新启动计数器点击或禁用它 - Javascript
这是JavaScript。
<script type="text/javascript">
x = 10;
function countdown() {
if (x > 1) {
x--;
document.getElementById("button").innerHTML = x;
r = setTimeout("countdown()",1000);
}
else {
clearTimeout(r);
document.getElementById("button").innerHTML = "Click to download";
document.getElementById("button").disabled = "";
}
}
r = setTimeout("countdown()",1000);
</script>
这里是按钮,
<label><font size="5">Your download will start in: </label><a href="download.php?shortURL=<?php echo $fullfile; ?>"><button class="btn orange" id="button" disabled="disabled" onclick="window.location.reload()" >10</button></font></a>
谢谢!
? – 2012-02-07 18:37:15
请注意,您的HTML格式不正确 - ''标签必须在关闭'
没问题,我只是想当你点击按钮时,让柜台再次启动 – HarryBeasant 2012-02-07 18:40:21