zoukankan      html  css  js  c++  java
  • 比较appendChild和insertBefore的区别

    <html>
    <script>
    function fnAppend(){
    var oNewNode = document.createElement("DIV");
    oList.appendChild(oNewNode);
    oNewNode.innerText="List node 5";
    }

    function Insert(){
    var oNewNode = document.createElement("DIV");
    oList.parentNode.insertBefore(oNewNode,oList);
    oNewNode.innerText="List node 6";
    }
    </script>
    <body>
    我在做测试啦!
    <br>
    比较appendChild和insertBefore的区别
    <div id = oList>
    <div>List node 1</div>
    <div>List node 2</div>
    <div>List node 3</div>
    <div>List node 4</div>
    </div>
    <input type = "button" value = "Append Child" onclick = "fnAppend()" /><br />
    <input type = "button" value = "InsertBefore" onclick = "Insert()" />
    </body>
    </HTML>
  • 相关阅读:
    CSS三大特性
    CSS选择器
    CSS(1)
    多媒体标签
    快捷键
    H5注意点(2)
    H5注意点(1)
    List详解
    求最大子串和以及其中一个子串(java)
    隧道项目
  • 原文地址:https://www.cnblogs.com/zwei1121/p/688516.html
Copyright © 2011-2022 走看看