-2
我一直在試圖找到一種創建JS按鈕的不可思議的方式,但我無法理解父節點的子節點吃什麼。我感覺如此接近完善我的小遊戲,但無法完成。我該如何製作一個帶有HTML風格屬性的JS按鈕
var health=100;
var ehealth=100;
var atk;
var eatk;
function attack(x){
x=Math.floor(Math.random()*11);
atk=x;
ehealth=ehealth-atk
document.write('Enemy Health:' + ' ' + ehealth + ' ')
}
function eattack(x){
x=Math.floor(Math.random()*11);
eatk=x;
health=health-eatk
document.write('Health:' + ' ' + health + '<br/>\n')
}
function dead(){
if(health<=0&&ehealth<=0){
document.write('A Draw');
}else{
if(health<=0){
document.write('You Lose');
}else{
if(ehealth<=0){
document.write('You Win');
}
}
}
}
function battleRound() {
attack(0);
eattack(0);
dead();
if(health>=0&&ehealth>=0) {
setTimeout(battleRound, 400);
}
}
</script>
<button onclick='battleRound()'>Start</button>
<button onclick="document.location.reload(true)">Reset</button>
</body>
我想復位按鈕出現在戰鬥後完成,但整個互聯網似乎尖叫:( 4問題我今天問我很抱歉子節點和家長一些新手,ish-網元
在冠冕堂皇厚的風險,什麼是風格 – Clarinetking
+1可能?我會怎麼做,但如果你真的想要t o創建一個新的,IMO使用jQuery,它比本地JS – CompanyDroneFromSector7G
風格標記更簡單,例如, '' – CompanyDroneFromSector7G