So fügen Sie HTML in JavaScript ein
var h = document.getElementById("myH2");
h.insertAdjacentHTML("afterend", "<p>My new paragraph</p>");
Anthony Smith
var h = document.getElementById("myH2");
h.insertAdjacentHTML("afterend", "<p>My new paragraph</p>");
//adding 'p' tag to body
var tag = document.createElement("p"); // <p></p>
var text = document.createTextNode("TEST TEXT");
tag.appendChild(text); // <p>TEST TEXT</p>
var element = document.getElementsByTagName("body")[0];
element.appendChild(tag); // <body> <p>TEST TEXT</p> </body>
//create div
let div = document.createElement('div');
//create button
let button = document.createElement('button');