62,268
社区成员
发帖
与我相关
我的任务
分享
<script language=javascript>
function add()
{
alert("1");
//添加节点
var newElement=document.createElement("p");
newElement.innerText="内容";
document.getElementById('paragraphs').appendChild(newElement);
}
function del()
{
//删除节点
all = document.getElementById("paragraphs").childNodes;
document.getElementById("paragraphs").removeChild(all[all.length -1]);
}
</script>
<div id="paragraphs">
<p id="p1">段落1</p>
<p id="p2">段落2</p>
</div>