1 //adding 'p' tag to body
2
3 var tag = document.createElement("p"); // <p></p>
4 var text = document.createTextNode("TEST TEXT");
5 tag.appendChild(text); // <p>TEST TEXT</p>
6 var element = document.getElementsByTagName("body")[0];
7 element.appendChild(tag); // <body> <p>TEST TEXT</p> </body>
1
2<div id="new">
3<p id="p1">Tutorix</p>
4<p id="p2">Tutorialspoint</p>
5</div>
6<script>
7 var tag = document.createElement("p");
8 var text = document.createTextNode("Tutorix is the best e-learning platform");
9 tag.appendChild(text);
10 var element = document.getElementById("new");
11 element.appendChild(tag);
12</script>
1// correct me if im wrong
2var MainDiv = document.createElement('div');
3var ChildDiv1 = MainDiv.createElement('div');
4ChildDiv1.className = 'contextmenu_contextMenu_3_a2Z contextmenu_ContextMenuFocusContainer_2thYU';
5ChildDiv1.tabIndex = "0";
6ChildDiv1.style = "visibility: visible; bottom: 56px; right: 68px;"
7var ChildDiv2 = ChildDiv1.createElement('div');
8ChildDiv1.className = 'contextmenu_contextMenuContents_1yyTu';
9var DivButton1 = ChildDiv2.createElement('div');
10DivButton1.className = 'contextmenu_contextMenuItem_CBC-y contextMenuItem';
11DivButton1.value = "Upload an Image";
12var DivButton2 = ChildDiv2.createElement('div');
13DivButton2.className = 'contextmenu_contextMenuItem_CBC-y contextMenuItem';
14DivButton2.value = "Share Your Trade Offer URL";
15document.body.appendChild(MainDiv);