标签:
1.原生JS实现
1 <script type="text/javascript"> 2 var oTable = document.getElementById("table"); 3 var oTr = oTable.getElementsByTagName("tr"); 4 for (var i=0; i<oTr.length;i++) 5 { 6 if (i%2) 7 oTr[i].style.background = "yellow"; 8 } 9 </script>
2.Jquery实现
1 <script type="text/javascript"> 2 $(‘#table tr:even‘).css("background", "yellow"); 3 </script>
标签:
原文地址:http://www.cnblogs.com/aoun/p/4437792.html