<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>每天一个JavaScript实例-从一个div元素删除一个段落</title>
<style>
p{
padding:20px;
margin:10px 0;
width:400px;
background-color:#eef;
}
</style>
<script>
window.onload = function(){
var paras = document.getElementsByTagName("p");
for(var i=0;i<paras.length;i++){
paras[i].onclick = prun;
}
}
function prun(){
var parent = this.parentNode;
console.log(parent);
parent.removeChild(this);
alert("paras" + document.getElementsByTagName("p").length);
}
</script>
</head>
<body>
<div id = "date">
<p>one</p>
<p>two</p>
<p>three</p>
<p>four</p>
<p>five</p>
</div>
</body>
</html>