隔行变色

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>引入jQuery库</title>
    <script type="text/javascript" language="javascript" src="jquery-3.2.1.js"></script>
    <script>
    $(document).ready(function(){
        $("tr:odd").addClass("odd");
        $("tr:even").addClass("even")
    })
</script>
<style type="text/css">
    .odd{
        background-color: red;
    }
    .even{
        background-color: blue;
    }
</style>
</head>
<body>
<table border="1">
        <tr><td>学号</td><td>姓名</td><td>班级</td></tr>
       <tr><td>2015180001</td><td>张三</td><td>15信管本科班</td></tr>
       <tr><td>2015181001</td><td>李四</td><td>16信管本科班</td></tr>
    </table>
</body> </html>

 

posted @ 2017-10-30 09:26  勤奋的园  阅读(167)  评论(1编辑  收藏  举报