Javascript examples for DOM HTML Element:Article
You can create an <article> element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">create an ARTICLE element containing a H1</button> <script> function myFunction() {// w w w. j av a2 s. c o m var x = document.createElement("ARTICLE"); x.setAttribute("id", "myArticle"); document.body.appendChild(x); var heading = document.createElement("H1"); var txt1 = document.createTextNode("Heading in Article"); heading.appendChild(txt1); document.getElementById("myArticle").appendChild(heading); } </script> </body> </html>