<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] # DOM * [ ] 瀏覽器對象window ``` 直接使用window對象``` * [ ] 文檔對象document ```window.document 或 document``` * [ ] 節點對象NodeElement ``` Live Node = document.getElementById("id") Live Node List = document.getElementsByClassName("class") Live Node List = document.getElementsByName("name") Live Node List = document.getElementsByTagName("tagname") Static Node = document.querySelector("selector") Static Node List = document.querySelectorAll("selector") ``` ## 案例1:獲取節點屬性 | 屬性 | 說明 | | --- | --- | | nodeName | 節點的名稱(標簽名) | | ~~nodeType~~ | 節點的類型(NodeElement值為1)× | | ~~nodeValue~~ | 節點的值 × 并非value值 | | parentNode | 節點的父元素 | | childNodes | 節點的子元素列表(包含空白節點) | | firstChild | 節點的第一個子元素(可能會引用到空白節點) | | lastChild | 節點的最后一個子元素 | | previousSibling | 節點前一個兄弟 | | nextSibling | 節點后一個兄弟 | | attributes | 節點屬性列表(name=value形式) | ![](https://img.kancloud.cn/35/ba/35bad55900bffec4ce7200c071f152c4_287x161.png) ![](https://img.kancloud.cn/13/87/13876d24d685bee5cea1ceab64e129c0_371x181.png) ## 案例2:添加不同節點 ![](https://img.kancloud.cn/7d/fd/7dfd13cd215be263b63b83e46d1697f1_432x398.gif) > 試一試:增加兄弟節點(在某個節點之前) ``` ele.parentNode.insertBefore(newEle,ele); ``` ## 案例3:批量添加節點 ![](https://img.kancloud.cn/6f/2f/6f2fc28ad8c1ca8ba940d66c8ffbbf7f_432x398.gif) ## 案例4:刪除節點 ``` ele.parentNode.removeChild(ele); ``` ![](https://img.kancloud.cn/42/30/423069be8c5120b76acc13699bfd709c_432x398.gif) ## 案例5:節點克隆與替換(了解) ``` ele.parentNode.append(ele.cloneNode(true)); ele.parentNode.replaceChild(newEle,ele); ``` ![](https://img.kancloud.cn/bb/8e/bb8e40414f34be9faf603c0181886b92_428x388.gif) # BOM ## 案例1:網頁跳轉 ![](https://img.kancloud.cn/6f/cc/6fcc8d04337452af9fabfab90bd404b6_890x588.gif) ## 案例2:打開/關閉窗口 ``` myWindow = window.open("https://www.baidu.com","baidu","width=800,height=600,top=200,left=600") myWindow.close(); ``` > JavaScript只能關閉自己打開的窗口,不能控制已經打開的其他窗口 ![](https://img.kancloud.cn/72/bc/72bc3ed4f0750df26e1218f2d2809fe0_1112x720.gif) [鏈接:http://www.cac.gov.cn/2022-09/08/c_1664260384702890.htm](http://www.cac.gov.cn/2022-09/08/c_1664260384702890.htm) ![](https://img.kancloud.cn/8e/21/8e2103f175f775f51e002b7f0890fdd2_1144x710.png) ![](https://img.kancloud.cn/66/0e/660e8b9b56b7743946e885453a30efe9_974x795.png) ## 案例3:交互框 ![](https://img.kancloud.cn/33/69/33699dcfcfb9524003a94bbc3ef1e52b_498x339.gif) ### 試一試:自動跳轉 ![](https://img.kancloud.cn/27/1d/271d65dd799299ba625f9400078e3c65_666x406.gif) ## 案例4:網頁打字機 ![](https://img.kancloud.cn/49/78/497867d58ec455ad02061009173516c8_666x406.gif) ### 試一試:定時跳轉 ![](https://img.kancloud.cn/48/ca/48cac20fcb98ea5021e4d71d9c9e3ae5_580x360.gif) ## 案例5:控制窗口歷史記錄 ``` window.history.forward(); window.history.back(); window.history.go(index); ``` ![](https://img.kancloud.cn/79/e7/79e7aebeb0008942b4b46154892096f4_666x406.gif) ## 案例6:自動記錄信息(刷新網頁不丟失) ``` document.cookie = cname+"="+cvalue+";expires="+new Date().toGMTString();"; var cookies = document.cookie.split(';'); ``` ![](https://img.kancloud.cn/39/ce/39ce0db69db495b9a6e5192ac00fa751_450x402.gif)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看