zoukankan      html  css  js  c++  java
  • 第二部分1.3遍历dom

    最后一个任务有意思。

      书上看来以为自己会了是假的,做题实践用出来才是正途。

            first last 快捷方式,要是批量处理还是用下表法通用。
            体会到循环的诞生原因,就是因为重复的东西需要写好多遍。
            不知道为啥,firefox会自动在html文档中的table下添加tbody,如果你没写的话。

    /*
        document.body.firstElementChild.firstElementChild.firstElementChild.firstElementChild.style.backgroundColor = "red";
        document.body.firstElementChild.firstElementChild.children[1].children[1].style.background = "red";
        document.body.firstElementChild.firstElementChild.children[2].children[2].style.background = "red";
        document.body.firstElementChild.firstElementChild.children[3].children[3].style.background = "red";
        document.body.firstElementChild.firstElementChild.children[4].children[4].style.background = "red";
        */
        
        /*
            first last 快捷方式,要是批量处理还是用下表法通用。
            体会到循环的诞生原因,就是因为重复的东西需要写好多遍。
            不知道为啥,firefox会自动在html文档中的table下添加tbody,如果你没写的话。
        */
        /*
        //while循环版本
        let i = 0;
        while (i < 5) {
            document.body.children[0].children[0].children[i].children[i].style.background = "red";
            i++;
        }
        */
        
        //for循环版本
        for (let i = 0; i < 5; i++) {
            document.body.children[0].children[0].children[i].children[i].style.background = "red";    
        }

  • 相关阅读:
    Flex通信-Java服务端通信实例
    myeclips破解
    最简单的基于FFmpeg的移动端例子:Android 视频转码器
    Kapacitor行为测试
    mydumper备份原理和使用方法
    csdn课堂学习
    maven 遇到failOnMissingWebXml有关问题解决方法
    Oracle中NVL、NVL2、DECODE函数的用法
    Mybatis 一对多 多对1
    Linux编译ffmpeg
  • 原文地址:https://www.cnblogs.com/JuniorProgramer/p/14897419.html
Copyright © 2011-2022 走看看