loading...

re: What's your preferred method for inserting DOM elements in vanilla JS? VIEW POST

FULL DISCUSSION
 

Handling complex DOM manipulations with vanillaJS is tough.
For simple cases I use createElement() and fullfill the element with innerHTML:

let title = 'DOM Manipulation';
let description = '🤔';
let el = document.createElement('div');
el.innerHTML = `
<h1>${title}</h1>
<p>${description}</p>
`;
document.body.appendChild(el);
Code of Conduct Report abuse