Home > Web Front-end > JS Tutorial > Implementation code display of JS control table alternating row color

Implementation code display of JS control table alternating row color

巴扎黑
Release: 2017-05-21 18:48:08
Original
2373 people have browsed it

<table width="800" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td>不变色</td>
    </tr>
    <tbody id="goaler">
    <tr>
        <td>xxxxxxxx</td>
    </tr>
    <tr>
        <td>xxxxxxxx</td>
    </tr>
    <tr>
        <td>xxxxxxxx</td>
    </tr>
    <tr>
        <td>xxxxxxxx</td>
    </tr>
    </tbody>
    <tr>
        <td>不变色</td>
    </tr>
</table>
<script language="JavaScript">
<!--
var TbRow = document.getElementById("goaler");
if (TbRow != null)
{
    for (var i=0;i<TbRow.rows.length ;i++ )
    {
        if (TbRow.rows[i].rowIndex%2==1)
        {
            TbRow.rows[i].style.backgroundColor="";
        }
        else
        {
            TbRow.rows[i].style.backgroundColor="#F1F1F1";
        }
    }
}
//-->
</script>
Copy after login

The above is the detailed content of Implementation code display of JS control table alternating row color. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template