如题:
我做了个网页,需要这样实现,第一行是背景是蓝色的,第二行和第三行是白色的,第四行是蓝色的,第五行和第六行是白色的,第七行是蓝色的,以此类推每个两行显示一个蓝色背景的,请问用jquery或者js怎样实现???????、

解决方案 »

  1.   

    http://v3.thewatchmakerproject.com/zebra.html
      

  2.   


       $(function(){
                $("tr").each(function(i){  //我这里假设的是tr,根据LZ自己的来
                    if(i % 3 == 0)
                       $(this).css("background-color","blue");
                    else
                       $(this).css("background-color","white");
                });
               
            });
      

  3.   

    也可以:
             $("table").css("backgroundColor", "#0000ff");
            $("tr").each(function(index) {
                    $(this).not(":eq(" + index % 3 + ")").css("backgroundColor", "#fff");
            }
      

  4.   

            $("table").css("backgroundColor", "#0000ff");
            $("tr").each(function(index) {
                    $(this).not(":eq(" + index % 3 + ")").css("backgroundColor", "#fff");
                });