How to insert a large block of HTML in JavaScript? - Stack Overflow

PHOTO EMBED

Sun Sep 19 2021 14:16:40 GMT+0000 (Coordinated Universal Time)

Saved by @Mufaddal #javascript

// Create a temporary <div> to load into
var div = document.createElement('div');
div.setAttribute('class', 'someClass');
div.innerHTML = document.getElementById('blockOfStuff').innerHTML;

// You could optionally even do a little bit of string templating
div.innerHTML = div.innerHTML
    .replace(/{VENDOR}/g, 'ACME Inc.')
    .replace(/{PRODUCT}/g, 'Best TNT')
    .replace(/{PRICE}/g, '$1.49');

// Write the <div> to the HTML container
document.getElementById('targetElement').appendChild(div);
content_copyCOPY

https://stackoverflow.com/questions/16270761/how-to-insert-a-large-block-of-html-in-javascript/16270807