[Solved] Style.display block/none problems


Demo FIDDLE

HTML

     <body onload="disappear()">
    <table border="1" >
        <tr>
            <td><img id="SHP" src="https://stackoverflow.com/questions/21594042/Hp/HPSlayerzach/hp2.png"/></td>
            <td></td>
            <td><img src="characters/slayerzach/slayerzach.png"/></td>
        </tr>
        <tr>
            <td><p id="demo"></p></td>
            <td ><img id="att" src="backgrounds/spacer1.png"/></td>
            <td></td>
        </tr>
        <tr>
            <td><img align="right" src="characters/fighterdan13/fighterDan13.gif"/></td>
            <td></td>
            <td><img id="FHP" src="hp/HPFighterdan13/hp1.png"/></td>
        </tr>
        <tr>
            <td colspan="2" background="backgrounds/backgroundText.png">
                <center><table border="0" id="list">
                    <tr>
                        <td style="font-family:verdana;font-size:15px"><center><a onclick="fire()">FIRE</a></center></td>
                        <td style="font-family:verdana;font-size:15px"><center>LIGHTNING</center></td>
                    </tr>
                    <tr>
                        <td style="font-family:verdana;font-size:15px"><center>WATER</center></td>
                        <td style="font-family:verdana;font-size:15px"><center>EARTH</center></td>
                    </tr>
                </table></center>
                <div id="message"></div>
            </td>
            <td>
                <center><table border="0" background="backgrounds/backgroundmenu.png">
                    <tr>
                        <td><button id="butAtt" onclick="attack()">Attack</button></td>
                        <td><button id="butItems" disabled>Items</button></td>
                    </tr>
                    <tr>
                        <td colspan="2"><center><button id="butRun" style="width:110px; height:25px;" disabled>Run</button><center></td>
                    </tr>
                </table></center>
            </td>
        </tr>
    </table>      
</body>

CODE

    function attack(){
        document.getElementById("list").style.display="block";
        document.getElementById("message").innerHTML="";
    }
    function fire(){    
        var y=document.getElementById("message");   
        var x=document.getElementById("demo");
        var z=document.getElementById("att");
        x.innerHTML=3;
   }
function disappear(){
    document.getElementById("list").style.display="none";   
    document.getElementById("message").innerHTML="<center>Wild SlayerZach has appeared.</center>";
}

Problem was you replace the message innerhtml on disappear.it remove the table which have id list.so i create div with id message inside the td and remove message id from the td.

5

solved Style.display block/none problems