想用JAVASCRIPT写一段程序,用于清除表格中所有单元格现有的背景色,请问代码该如何写?

解决方案 »

  1.   

    #TblId * td{background-color:transparent!important;}
      

  2.   

    <style>
    .test {background-color:#000000;}
    </style>
    <table id="tb1">
    ....
    </table>
    <script>
    document.getElementById("tb1").className="test";
    //或直接
    document.getElementById("tb1").style.backgroundColor="";
    </script>
      

  3.   

    得根据你那个是TD颜色还是TR颜色还是TABLE的颜色来决定怎么做,不然大家给你的方法都不能完全对照你的写法的,最好帖代码出来。
    document.getElementsByTagName("table或者tr或者td").style.backgroundColor='xxxxxxxxxx'