码迷,mamicode.com
首页 > Web开发 > 详细

js隔行换色

时间:2017-09-15 16:37:38      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:数组   nload   style   遍历数组   length   col   func   document   tag   

<script>

     //加载页面

  onload = function(){

  //获取所有的tr

  var arr = document.getElementsByTagName("tr");

  //判断行的奇偶,添加不同的样式,遍历数组

  for(var i = i;i < arr.length;i++){

  if(i % 2 == 0){

  arr[i].style.backgroundColor="#ffffff";

}else{

  arr[i].style.backgroundColor="#BC680D";

}

}

}

</script>

js隔行换色

标签:数组   nload   style   遍历数组   length   col   func   document   tag   

原文地址:http://www.cnblogs.com/wqdyxnbd/p/7526664.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!