怎样创建一个新的节点并插入到文档中

1. 创建一个新的节点: document.createElement()

2. 插入新创建出来的节点: Node.prototype.appendChild()

var p = document.createElement("p");
p.innerText = "helloWorld";
document.body.appendChild(p);

猜你喜欢

转载自www.cnblogs.com/aisowe/p/11508487.html