| 123456789101112131415161718192021222324252627282930313233343536373839404142 | <!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <meta http-equiv="X-UA-Compatible" content="IE=edge">  <meta name="viewport" content="width=device-width, initial-scale=1.0">  <title>Document</title></head><body>  <div id="div1">    <p id="p1">123</p>    <p>456</p>  </div>  <script>    var a = document.createElement('p')    var b = document.createTextNode('789')    console.log(a)    console.log(b)    a.appendChild(b)    console.log(a)    //appendChild 向html里面添加新元素  必须先创建元素接待你 然后追加    var div1 = document.getElementById('div1')    // div1.appendChild(a)    var p1 = document.getElementById('p1')    //insertBefore(参数1,参数2)  向参数2前面添加参数1    // div1.insertBefore(a,p1)        //xx.remove()在页面中删除xx节点    // p1.remove()    //xx.removeChild()移除XX里面的子节点    // div1.removeChild(p1)    //xx.replaceChild(新节点,旧节点)    div1.replaceChild(a,p1)  </script></body></html>
 |