日期:2014-05-16 浏览次数:20414 次
<script type="text/javascript">
?window.onload = function() {
?
??var myTable = document.getElementById("myTable");
??var myTBody = myTable.getElementsByTagName("tbody")[0];
??var myTR = myTBody.getElementsByTagName("tr");
??
??alert("总共? " + myTR.length + " 条记录");
??
??for ( var i = 0; i < myTR.length; i++) {
???if (i % 2 == 0) {
????myTR[i].style.background = "red";
???} else {
????myTR[i].style.background = "green";
???}
??}
?}
</script>