a.appendChild (b) adding a tag is the parent of b, b to a is added to the
Additional tag a.insertBefore (b, c); a is the parent of b and c, b is inserted in front of the c
Remove label a.removeClild (b) a parent is b, b delete label
Case:
(1)html
<input type="text" id="txt">
<button id="btn">按钮</button>
<div id="box">
<p id="P1">这是第一个P <span id='close'>X</span></p>
</div>
(2)JavaScript
ABB function (A) {
return document.getElementById (A);
}
var P;
. ABB ( 'BTN') the onclick = function () {
P = document.createElement ( 'P');
p.innerHTML = ABB ( 'TXT ') .Value;
the console.log (P);
// ABB (' Box ') the appendChild (P);.
ABB (' Box '.) insertBefore (P, ABB (' Box ') Children [0]).;
// append tag a.insertBefore (b, c); a is the parent of b and c, b is inserted in front of the c
}
ABB ( 'Close') the onclick = function () {.
// ABB ( 'Box') the removeChild (this.parentNode);.
This.parentNode.parentNode.removeChild (this.parentNode);
// delete labels a.removeClild (b) a is the parent of b, b delete tag
}