Inserting arbitrary HTML into a DocumentFragment

前端 未结 11 2114
花落未央
花落未央 2020-11-29 18:53

I know that adding innerHTML to document fragments has been recently discussed, and will hopefully see inclusion in the DOM Standard. But, what is the workaround you\'re sup

11条回答
  •  日久生厌
    2020-11-29 19:17

    var html = '
    x
    y'; var frag = document.createDocumentFragment(); var e = document.createElement('i'); frag.appendChild(e); e.insertAdjacentHTML('afterend', html); frag.removeChild(e);

提交回复
热议问题