节点操作基础知识回顾:

var body = document.body;
var html = document.documentElement;
var div = document.createElement("div");
var p = document.createElement("p");
var ali = document.createTextNode("alipay");
p.appendChild(ali);
div.appendChild(p);
div.setAttribute("id","fn-div");
div.setAttribute("class","fn-class");
body.appendChild(div);

var arr = div.attributes;
for(var i=0;i<arr.length;i++){
console.log(arr[i].name + ":" + arr[i].value);
}



相关文章:

  • 2022-12-23
  • 2021-10-23
  • 2022-12-23
  • 2022-01-29
  • 2022-02-07
  • 2022-01-26
  • 2021-05-30
  • 2022-01-12
猜你喜欢
  • 2021-12-22
  • 2021-05-07
  • 2021-11-18
  • 2021-08-05
  • 2021-06-27
  • 2021-10-19
相关资源
相似解决方案