26
loading...
This website collects cookies to deliver better user experience
// Let us assume we want to add some html markup inside some element with the id of x12
const markup = `<div>
<h1>This is some dummy markup </h1>
</div>
`;
document.getElementById("x12").innerHTML = markup;
element.insertAdjacentHTML(position, text);
// Let us assume we want to add some html markup inside some element with the id of x12
const markup = `<div>
<h1>This is some dummy markup </h1>
</div>
`;
document.getElementById("x12").innerHTML = markup;
const element = document.createElement(elementType);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>append and appendChild methods</title>
</head>
<body>
</body>
</html>
const div = document.createElement('div');
div.innerHTML = '<p>This is a div element</p>';
// Append the div as a child element to the body element.
document.body.appendChild(div);