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

  • 相关阅读:
    Swift Optional
    cocoapods 配置
    winform窗体全屏
    SQLiteDatabase的使用
    探索Gallery和ImageSwitcher布局
    常用布局参考
    增加动画的效果
    AlertDialog的写法
    自定义Toast
    适配器的经典写法
  • 原文地址:https://www.cnblogs.com/JuniorProgramer/p/14897419.html
Copyright © 2011-2022 走看看