1、

function createNode(htmlStr) {
    var div = document.createElement("div");
    div.innerHTML = htmlStr.trim();
    return div.childNodes[0];
}

2、

function createNode(htmlStr) {
  var div = document.createElement("div");
  div.innerHTML = htmlStr.trim();
  return div.firstChild;
}

 

相关文章:

  • 2021-10-29
  • 2021-10-16
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-16
  • 2021-10-02
  • 2022-02-10
  • 2021-09-12
  • 2021-12-08
  • 2022-12-23
相关资源
相似解决方案