Dom 结点创建 基础知识_DOM
程序员文章站
2022-05-18 13:37:38
...
复制代码 代码如下:
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
}