首页 > 代码库 > div实现隔行变色

div实现隔行变色

<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>    <title></title>    <style type="text/css">        .one {            color:green;            /*background-color:black;*/        }        .two {            color:red;            /*background-color:red;*/        }    </style>    <script src="http://www.mamicode.com/Js/jquery.js"></script>    <script type="text/javascript">        $(function () {            $(".alone").children("div:first").css("background-color", "#fcfcfc");            $(".alone").children("div:even").addClass("one");            $(".alone").children("div:odd").addClass("two");        });    </script></head><body>    <div class="alone">    <div>0000000</div>    <div>1111111</div>    <div>2222222</div>    <div>3333333</div>    <div>4444444</div>    <div>5555555</div>    <div>-------</div>    <div>6666666</div>    </div></body></html>

排除第一行变色,剩下的都变色

 

div实现隔行变色