Jquery隔行变色(原创)

<!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>
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-1.6.2.js"></script>
    <script type="text/javascript">
        $(function () {
            $("tr:even").css("background-color", "green");
            $("tr:first").css("background-color", "orange");
            $("tr").last().css("background-color", "silver")
        });
    </script>
    <style type="text/css">
        td
        {
            border:1px solid black;
        }
    </style>
</head>
<body>
    <table style="border:1px solid black;width:450px;border-collapse:collapse;">
        <tr><td>1</td><td>1</td><td>1</td><td>1</td></tr>
        <tr><td>1</td><td>1</td><td>1</td><td>1</td></tr>
        <tr><td>1</td><td>1</td><td>1</td><td>1</td></tr>
        <tr><td>1</td><td>1</td><td>1</td><td>1</td></tr>
        <tr><td>1</td><td>1</td><td>1</td><td>1</td></tr>
        <tr><td>1</td><td>1</td><td>1</td><td>1</td></tr>
        <tr><td>1</td><td>1</td><td>1</td><td>1</td></tr>
        <tr><td>1</td><td>1</td><td>1</td><td>1</td></tr>
        <tr><td>1</td><td>1</td><td>1</td><td>1</td></tr>
    </table>
</body>
</html>
posted @ 2012-06-26 15:14  ``炯``  阅读(191)  评论(0编辑  收藏  举报