http://topic.csdn.net/t/20051027/21/4355310.html

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>背景交替显示</title>
    <script language="javascript">
        function changbgcolor(){
    var objrows=document.getElementsByTagName("tr");
    var i=0;
    while(objrows.item(i)){
        if(i%2==0)
            objrows.item(i).style.backgroundColor="#000000";
    i++;
    }
    }
    </script>
    </head>
    <body onload="changbgcolor()">
    <table width="344" border="1" align="center">
      <tr>
        <td width="103">&nbsp;</td>
        <td width="117">&nbsp;</td>
        <td width="102">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    </body>
    </html>
    在ie和firefox下调试通过
      

  2.   

    表格间隔行换色
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title></title>
    <style type="text/css">
    <!--
    tr {background-color:expression((this.sectionRowIndex%2==0)?"red":"blue")}
    -->
    </style>
    </head>
    <body>
    <TABLE>
    <TR><TD>1</TD></TR>
    <TR><TD>1</TD></TR>
    <TR><TD>1</TD></TR>
    <TR><TD>1</TD></TR>
    <TR><TD>1</TD></TR>
    <TR><TD>1</TD></TR>
    </TABLE></body>
    </html>