<script>
var tic;
tic = 0;
</script>
<script>
var ongngic;
ongngic = 1;
</script>
<button onclick="alert(tic=tic+ongngic);">Ice Cream</button>
<button id= "b1" onclick="alert(ongngic=ongngic+1, tic=tic-10);" disabled="disabled">Buy 'Jimmy's Ice Cream Stand' - 10 Ice Cream</button>
<script>
function myFunction() {
document.getElementById("b1").enabled = true;
}
</script>
<script>
if(var tic > 9){
myFunction();
}
</script>
當我點擊'冰淇淋'按鈕10次,id = 1按鈕應該啓用,但不。誰能幫我?如何使用if語句啓用按鈕?
那麼你應該把它每次更新變量。 – epascarello
當'tic === 0'時,if(var tic> 9){}'只在頁面加載時運行*一次*。 –
爲什麼會有這麼多'script'標籤? –