Dom 结点创建 基础知识
时间:2021-07-26 07:52:44|栏目:|点击: 次
复制代码 代码如下:
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);
}
上一篇:使用VMware10安装Ubuntu 14步骤图文详解
栏 目:
下一篇:docker 容器上编译 go 程序提示找不到文件问题
本文标题:Dom 结点创建 基础知识
本文地址:http://www.codeinn.net/misctech/161435.html






