码迷,mamicode.com
首页 > Web开发 > 详细

JS实现表格自动隔行换色

时间:2015-05-20 17:58:45      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>JS实现表格自动隔行换色丨石家庄冷风机|</TITLE>
    </HEAD>
    <BODY>
    <style>
    .t1 {background-color:#C8FC98;text-align:center}
    .t2 {background-color:#ffffff;text-align:center}
    </style>
    <table id="table1" width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr><td>jsjsdjksdfdfgdfd</td></tr>
    <tr><td>vrtbtynyudegbg</td></tr>
    <tr><td>btrgjyjyukmymy</td></tr>
    <tr><td>fvdfthdhyjd</td></tr>
    <tr><td>htyjertyuktuijcdukdetyjety</td></tr>
    <tr><td>fdghrguiowheruighiaue</td></tr>
    <tr><td>aosiiopweorhwdebfcjlhaSD</td></tr>
    <tr><td>SDHFKAJBNELFJAOSDFA</td></tr>
    <tr><td>sdafasdgdasfgggggggasdffasd</td></tr>
    <tr><td>sjdfkjherhtuiehrjfhgsjghghdfgd</td></tr>
    <tr><td>asdfgasdddddddddddd</td></tr>
    <tr><td>fghdhgdfhfg</td></tr>
    <tr><td>shdfsjitirueruiwoiwopeirwueitu</td></tr>
    <tr><td>sjdfkjherhtuiehrjfhgsjghghdfgd</td></tr>
    <tr><td>sjdfkjherhtuiehrjfhgsjghghdfgd</td></tr>
    </table>
    <script Language="Javascript1.2">
    for (i=0;i<table1.rows.length;i++) {
    (i%2==0)?(table1.rows(i).className = "t1"):(table1.rows(i).className = "t2");
    }
    </script>
    </BODY>
    </HTML>
    <br>随便添加一行试试~<br><hr>

 

JS实现表格自动隔行换色

标签:

原文地址:http://www.cnblogs.com/zhaozzm/p/4517711.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!