我正在創建一個計數器,我很難做到這一點。 計數器的目標是永遠第二通過多項將由170 增加,因爲你可以看到下面的數字不加起來並在新線由,主要是因爲我不知道如何使它加起來。像這樣的時鐘從The Economist創建計數器
<!DOCTYPE html>
<html>
<body>
<p>Click the button see how much AirHelps market increases by every second.</p>
<button onclick="counterFunction()">See it now</button>
<p id="counter"></p>
<script>
function counterFunction() {
setTimeout(function() {
var text = "";
var i = 170;
while (i < 3500) {
text += "<br>The number is " + i;
i+=170;
}, 1000) }
document.getElementById("counter").innerHTML = text;
}
</script>
</body>
</html>
任何想法如何,我可以讓這個什麼東西有些是錯我的代碼?
'p'在170遞增下去,不是1。這是錯誤的。 –
謝謝你,編輯了回覆 – jstuartmilne