I have the following JavaScript that creates a div and then appends it to the body and then inserts some dynamically generated HTML into it. cartDiv = document.createElement
Not sure if this is the best way, but it works.
if (cartDiv == null) { cartDiv = ""; // document.createElement('div'); document.body.appendChild(cartDiv); }