1<html>
2<head>
3<title>t1</title>
4<script type="text/javascript">
5 function addNode()
6 {var newP = document.createElement("p");
7 var textNode = document.createTextNode(" This is a new text node");
8 newP.appendChild(textNode);
9 document.getElementById("firstP").appendChild(newP); }
10</script> </head>
11<body> <p id="firstP">firstP<p> </body>
12</html>
13
1const e = document.createElement('div');
2e.innerHTML = 'JavaScript DOM';
3document.body.appendChild(e);