代码语言:javascript复制
<!--使table背景颜色交替变换-->
<script>
var table1 = document.getElementById("tbname");
var rows = table1.getElementsByTagName("tr");
for(var i=0;i<rows.length;i ){
if(i%2==0){
rows[i].style.backgroundColor='red';
}else{
rows[i].style.backgroundColor='green';
}
}
</script>