我想知道如何在每次計時器重新開始時輸入消息。這裏是我的代碼至今:JavaScript函數重新啓動後,您如何顯示消息?
<head>
<script type="text/javascript">
var c=10;
var t;
var timer_is_on=0;
function timedCount() {
document.getElementById('txt').value = c;
c = c - 1;
if (c == 0)
c = 10;
}
function doMining() {
if (!timer_is_on) {
timer_is_on = true;
t = setInterval(function() {
timedCount();
}, 1000);
}
}
</script>
<SPAN STYLE="float:left">
<form>
<input type="button" value="Mining" onClick="doMining()">
<input type="text" id="txt">
</form>
</SPAN>
好的,謝謝:D生病嘗試一下,感謝提示 – Mason 2011-02-23 06:25:09
OK:P我想這一點,計時器無法啓動 – Mason 2011-02-23 06:30:02
哦,變 「的appendChild(TXT)」 到 「使用appendChild(_message)」。我的錯。 – 2011-02-23 07:14:53