我有這個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