<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>游戲</title></head><body> <input type='text' id='txt' /> <input type='button' value='確定' onclick="s()"/> <script> var i=Math.ceil(Math.random()*100); function s(){ var a=document.getElementById("txt").value; if(a==i){ alert("恭喜你答對了") }else if(a<i){ alert("太??!") }else if(a>i){ alert("太大!") } for(var y=5;0<y;y--){ if (y<=5) { alert("還有"+y+"次機會") } } } </script></body></html>//我想讓這行代碼每次只彈一次 5、4、3、2、1這樣,來個大神幫我寫一下吧。for(var y=5;0<y;y--){if (y<=5) {alert("還有"+y+"次機會")}
js 寫的一個猜數(shù)字游戲。。。
你造嗎_
2015-11-22 00:17:06