阅读背景:

JS代码片段:appendHTML 和 insertAdjacentHTML

来源:互联网 
function appendHTML(container,html,position){
    position =position || 'after';
    var objE = document.createElement("div"),
        nodes=null,
        fragment = document.createDocumentFragment();
    objE.innerHTML = html;
    nodes=objE.childNodes;
    for (var i=0, length=nodes.length; i<length; i++) {
        fragment.appendChild(nodes[0]);
    }
    position !=='before'? container.appendChild(fragment) : container.insertBefore(fragment,container.firstChild);

    nodes = null;
    fragment = null;

}
function appendHTML(container,html,position



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: