jquery过滤选择器隔行变色

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<ul>
    <li>我是第1个li</li>
    <li>我是第2个li</li>
    <li>我是第3个li</li>
    <li>我是第4个li</li>
    <li>我是第5个li</li>
    <li>我是第6个li</li>
    <li>我是第7个li</li>
    <li>我是第8个li</li>
    <li>我是第9个li</li>
    <li>我是第10个li</li>
</ul>
<script src="jquery-1.12.4.js"></script>
<script>
    $(function () {
        //下标为偶数的过滤
       $("li:even").css("backgroundColor", "red");
        //下标为奇数的过滤
        $("li:odd").css("backgroundColor", "cyan");
    });
</script>
</body>
</html>
原文地址:https://www.cnblogs.com/cuilichao/p/9804500.html