Add, remove and replace HTML elements.
HTML DOM elements syntax
Add, remove and replace HTML elements.
HTML DOM elements example
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <div id="div1"> <p id="p1">這是一個(gè)段落。</p> <p id="p2">這是另一個(gè)段落。</p> </div> <script> var para=document.createElement("p"); var node=document.createTextNode("這是一個(gè)新段落。"); para.appendChild(node); var element=document.getElementById("div1"); element.appendChild(para); </script> </body> </html>
Run instance ?
Click the "Run instance" button to view the online instance