📜  附加原始 html javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:33.758000             🧑  作者: Mango

代码示例1
function appendHtml(el, str) {
  var div = document.createElement('div');
  div.innerHTML = str;
  while (div.children.length > 0) {
    el.appendChild(div.children[0]);
  }
}
var html = '

Some Title

Some arbitrary text'; appendHtml(document.body, html); // "body" has two more children - h1 and span.