码迷,mamicode.com
首页 > 其他好文 > 详细

table表格隔行变色

时间:2018-10-19 00:18:58      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:initial   ann   jquer   esc   gen   desc   title   doc   minimum   

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name=‘description‘ content=‘表格的高级应用‘>
    <title>表格的高级应用</title>
    <script src="../jquery.js"></script>
    <script>
        window.onload = function () {
            var oTab = document.getElementById(tab1);


            for (var i=0; i<oTab.tBodies[0].rows.length; i++){
                if(i%2){
                    oTab.tBodies[0].rows[i].style.background=red;
                }else {
                    oTab.tBodies[0].rows[i].style.background=green;
                }
            }
        }
    </script>
</head>
<body>
<table id="tab1" border=‘1‘ width="500px">
    <thead>
        <tr>
            <td>ID</td>
            <td>gender</td>
            <td>name</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>01</td>
            <td>male</td>
            <td>John</td>
        </tr>
        <tr>
            <td>02</td>
            <td>female</td>
            <td>Ann</td>
        </tr>
        <tr>
            <td>03</td>
            <td>female</td>
            <td>Merry</td>
        </tr>
        <tr>
            <td>04</td>
            <td>female</td>
            <td>Jessis</td>
        </tr>
        <tr>
            <td>05</td>
            <td>male</td>
            <td>Jack</td>
        </tr>
        <tr>
            <td>ID</td>
            <td></td>
            <td>Apollo</td>
        </tr>
    </tbody>
</table>

</body>
</html>

 

table表格隔行变色

标签:initial   ann   jquer   esc   gen   desc   title   doc   minimum   

原文地址:https://www.cnblogs.com/apollo1616/p/9813468.html

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