<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
window.onload=function(){
document.getElementById("b1").onclick=function(){
//创建一个p标签
var p1=document.createElement("p");
var text=document.createTextNode("你好,我是你的新标签");
p1.appendChild(text);
document.getElementById("div").appendChild(p1);
}//删除标签
document.getElementById("b2").onclick=function(){
var d=document.getElementById("div");
var p1=document.getElement(p1);
d.removeChild(p1);
}
}
</script>
</head>
<body>
<h2>动态创建新标签</h2>
<div id="div"></div>
<input type="button" id="b1" value="创建"/>
<input type="button" id="b2" value="删除"/>
</body>
</html>
亲,改一成这样就可以了
<!DOCTYPE html>谢谢你,因为只能采纳一个答案,所以我只采纳第一位啦!不好意思!不过还是谢谢你的帮忙!