add id to dynamically created

后端 未结 6 2142
鱼传尺愫
鱼传尺愫 2020-12-23 18:48

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

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 19:22

    Not sure if this is the best way, but it works.

    if (cartDiv == null) {
        cartDiv = "
    "; // document.createElement('div'); document.body.appendChild(cartDiv); }

提交回复
热议问题