要有事件,才可以啊要不就是onload
要不就是onmouseover等等,才回激发变颜色

解决方案 »

  1.   

    <table>
    <tr id="tr1" bgcolor="#999999">
    <td  id="aaa" width="24" >aaa</td>
    <td   bgcolor="#006633">ccc</td>
    </tr>
    </table>
    <script type="text/javascript">
    <!--
    function fun(){
    document.getElementById("tr1").style.backgoundColor="#Fc3300";
    document.getElementById("aaa").style.backgoundColor="#ffffff";
    }
    //-->
    </script>
    <form name="form1" method="post" action="">  <input type="button" name="button"  onClick="fun()" value="aa"></form>这样算有事件了吗,也还不行。
      

  2.   

    document.getElementById("tr1").style.background="#Fc3300";
    改成BACKGROUND
      

  3.   

    document.getElementById("tr1").style.backgoundColor="#Fc3300";backgoundColor错了,应该是backgroundColor
      

  4.   

    <SCRIPT>
    function fnGetId(){
    document.getElementById("oDiv1").style.backgroundColor="#000000";
    //alert("sfsa");
    }
    </SCRIPT>
    <DIV ID="oDiv1">Div #1</DIV>
    <DIV ID="oDiv2">Div #2</DIV>
    <DIV ID="oDiv3">Div #3</DIV>
    <INPUT TYPE="button" value="kao" onclick="javascript:fnGetId()">
      

  5.   

    background 这个属性才是对的
      

  6.   

    呵呵,楼上对得!
    sytle.background才是对得!
    lz注意了!
      

  7.   

    <body  onload="abb()">
    <table>
    <tr>
    <td  id="aaa" bgcolor=blue >aaa</td>
    <td  id="ccc" bgcolor="#006633">ccc</td>
    </tr>
    </table>
    </body>
    <script type="text/javascript">
    <!--
    function abb(){
    document.getElementById("aaa").style.background="red";
    document.getElementById("ccc").style.background="yellow";
    }
    //-->
    </script>