var i=0;
function addChild()
{
var newchild=document.createElement("div");
document.getElementById("di").appendChild(newchild);
newchild.innerText="ok";
}
function addChild()
{
var newchild=document.createElement("div");
document.getElementById("di").appendChild(newchild);
newchild.innerText="ok";
}
JavaScript动态添加DOM元素
本文介绍了一种使用JavaScript动态向页面中添加div元素的方法。通过创建新的div元素并将其添加到指定的父元素中,同时设置其文本内容为'ok',实现了网页内容的动态更新。
1200

被折叠的 条评论
为什么被折叠?



