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";    
        }

  • 相关阅读:
    数据分析之可反复与独立样本的T-Test分析
    朗朗上口的两幅对联
    mysql编码、数据表编码查看和改动总结
    2014-04-19编程之美初赛题目及答案解析
    测试集群模式安装实施Hadoop
    笔记:常用排序算法
    笔记:常用排序算法
    安装Redis并测试
    常见架构风格举例总结
    转载:PostgreSQL SQL的性能提升
  • 原文地址:https://www.cnblogs.com/JuniorProgramer/p/14897419.html
Copyright © 2011-2022 走看看