-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyini.html
More file actions
74 lines (59 loc) · 2.09 KB
/
yini.html
File metadata and controls
74 lines (59 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf8"/>
<script type="text/javascript">
window.onload = function(){
// 鼠标移动改变背景,可以通过给每行绑定鼠标移上事件和鼠标移除事件来改变所在行背景色。
var otr=document.getElementsByTagName("tr");
for(var i=0;i<otr.length;i++){
otr[i].onmouseover=function(){this.style.backgroundColor="#f2f2f2";};
otr[i].onmouseout=function(){this.style.backgroundColor="#fff";};
};
// function del(obj){
// obj.parentNode.parentNode.removeChild();
// }
function add(){
alert();
var or=document.createElement("tr");
var od=[];
for(var i=0;i<3;i++){
od[i]=document.createElement("td");
}
var oa=document.createElement("a");
oa.href="javascript:del(this)";
oa.innerHTML="删除";
od[0].innerHTML="xh003";
od[1].innerHTML="dingidng";
od[2].appendChild(oa);
for(var i=0;i<3;i++){
or.appendChild(od[i]);
}
var otable=document.getElementsByTagName("table")[0];
otable.appendChild(or);
}
}
</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:del(this)" >删除</a></td> <!--在删除按钮上添加点击事件 -->
</tr>
<tr>
<td>xh002</td>
<td>刘小芳</td>
<td><a href="javascript:;" >删除</a></td> <!--在删除按钮上添加点击事件 -->
</tr>
</table>
<input type="button" value="添加一行" onclick="add()" />
</body>
</html>