复制代码 代码如下: even and odd <BR>$(function(){<BR> alert("第一种");<BR> $("tbody tr:even").css("background-color", "red");<BR> $("tbody tr:odd").css("background-color", "yellow");<br><br> alert("第二种");<BR> $("tbody tr").each(function (index){<BR> alert(index); <BR> if(0 == index%2)<BR> {<BR> $(this).css("background-color", "blue"); <BR> }<BR> if(1 == index%2)<BR> {<BR> $(this).css("background-color", "green"); <BR> }<BR> });<br><br> alert("第三种");<BR> rows = document.getElementsByTagName("tr");<BR> var length = rows.length;<BR> for(var i=0; i< length;i++){<BR> alert(i);<BR> if(0==i%2){<BR> rows[i].style.backgroundColor="#ffff00";<BR> }else<BR> {<BR> rows[i].style.backgroundColor="#0000FF";<BR> } <BR> }<BR>});<BR> aaa aaa aaa bbb bbb bbb aaa aaa aaa bbb bbb bbb aaa aaa aaa bbb bbb bbb