<html>
<body>
<p>Click the button to create an ARTICLE element containing a H1 and P element.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
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);
var para = document.createElement("P");
var txt2 = document.createTextNode("Paragraph in article.");
para.appendChild(txt2);
document.getElementById("myArticle").appendChild(para);
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_article_create by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:04:25 GMT -->
</html>