<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>制作一个表格,显示班级的学生信息</title>
<script type="text/javascript">
function removeChild(){
var otest=document.getElementById("table");
var node=otest.childNodes;
for(var i=0;i<node.length;i++){
var x=otest.removeChild(otest.childNodes[i]);
}
}
</script>
</head>
<body>
<table border="1" width="50%" id="table">
<tr>
<th>学号</th>
<th>姓名</th>
<th>操作</th>
</tr>
<tr>
<td>xh001</td>
<td>王小明</td>
<td><a href="javascript:removeChild();">删除</a></td> <!--在删除按钮上添加点击事件 -->
</tr>
<tr>
<td>xh002</td>
<td>刘小芳</td>
<td><a href="javascript:removeChild();">删除</a></td> <!--在删除按钮上添加点击事件 -->
</tr>
</table>
<input type="button" value="添加一行" onClick="add()" /> <!--在添加按钮上添加点击事件 -->
</body>
</html>