加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 创业 > 正文

HTML n种方法实现隔行变色的示例代码

发布时间:2020-11-25 01:22:53 所属栏目:创业 来源:网络整理
导读:这篇文章首要先容了HTML n种方法实现隔行变色的示例代码,文中通过示例代码先容的很是具体,对各人的进修可能事变具有必然的参考进修代价,必要的伴侣们下面跟着

//=>3.js第二种方法
                    //  for (var i=0; i<ulList.length; i++){
                    //      switch ( i % 3) {
                    //           case 0:
                    //            ulList[i].className = "bgColorYellow";
                    //            break;
                    //            case 1:
                    //            ulList[i].className = "bgColorRed";
                    //            break;
                    //            case 2:
                    //            ulList[i].className = "bgColorBlue";
                    //            break;

//      }
                    //  }
            //=>4.js第三种方法  colorArray+bgColorYellow...
               //  var colorArray = ["bgColorYellow","bgColorRed", "bgColorBlue"];
               // for (var i=0; i<ulList.length; i++){
                     //=> 说明: i%3=0 "bgColorYellow" colorArray[0]
                     //=>        i%3=1  "bgColorBlue"  colorArray[1]
                     //=>        i%3=2  "bgColorRed"   colorArray[2]
                     //=> i%3的余数是几多?就是我们当前必要到数组中通过此索引找到的样式类,而这个样式类则是当前li必要配置的class
                   //       ulList[i].className = colorArray[i % 3];
                         
                 //   }
            //=>5.js第四种方法
                    // for (var i=0; i<ulList.length; i++){
                    //     ulList[i].className = 'bg'+ (i%3); //=>隔三行变色修改样式类
                    //     //=>在改变之前把原有的样式类信息存储到自界说属性中
                    //     ulList[i].myOldClass= ulList[i].className;

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读