JavaScript HTML DOM ??
JavaScript HTML DOM ??
? HTML ?? ???
? HTML ?? ???
HTML DOM? ? ??? ????? ?? ??(?? ??)? ?? ?? ?? ??? ???? ???. ? ??.
<!DOCTYPE html> <html> <meta charset="utf-8"> <body> <div id="div1"> <p id="p1">This is a paragraph.</p> <p id="p2">This is another paragraph.</p> </div> <script> var para=document.createElement("p"); var node=document.createTextNode("This is new."); para.appendChild(node); var element=document.getElementById("div1"); element.appendChild(para); </script> </body> </html>
?? ??:
? ??? ??? <p> ??? ?????:
var para=document.createElement("p");
<p> ??? ???? ????? ?? ??? ??? ????. ? ??? ??? ??? ?????:
var node=document.createTextNode("This is a new Parallel.");
?? ?? ? ??? ??? <p> ??? ???? ???:
para.appendChild (node);
????? ?? ??? ? ??? ???? ???.
? ??? ?? ??? ????.
var element=document.getElementById("div1");
?? ??? ?? ?? ?? ? ??? ?????.
element.appendChild(para); ?? HTML ?? ??
<!DOCTYPE html> <html> <meta charset="utf-8"> <body> <div id="div1"> <p id="p1">This is a paragraph.</p> <p id="p2">This is another paragraph.</p> </div> <script> var parent=document.getElementById("div1"); var child=document.getElementById("p1"); parent.removeChild(child); </script> </body> </html>? HTML ???? ? ?? ?? ??(? ?? <p> ??)? ?? <div> ??? ???? ????. :
<div id="div1"> <p id="p1">This is a paragraph.</p> <p id="p2">This is another paragraph.</p> </div>?? ?? with id="div1": var parent=document.getElementById("div1");
id="p1"? <p> ?? ??:
?? ???? ?? ?? ??:
??? ????. DOM? ???? ?? ??? ?? ?? ??? ??? ???.
child.parentNode.removeChild ( child);
HTML DOM ????