-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path065元素的添加和删除.html
115 lines (109 loc) · 2.63 KB
/
065元素的添加和删除.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>无标题文档</title>
<style>
</style>
<link rel="stylesheet" href="css/bootstrap.css">
<script src="js/common.js"></script>
<script type="text/javascript">
window.onload = function(){
var btnlist = document.getElementsByClassName("deletebtn");
for(var i=0; i<btnlist.length; i++){
btnlist[i].onclick = function(){
//parentNode父节点
this.parentNode.parentNode.remove();
}
}
var savebtn = document.getElementsByClassName("savebtn");
savebtn.onclick = function(){
var tr = ...
var th
var td1 = ...
var td2 = ...
var td3 = ...
var delbtn = document.createElement("a");
delbtn.className = "btn btn-danger";
delbtn.onclick = function(){
this.parentNode.parentNode.remove();
}
}
}
</script>
</head>
<body>
<div class="container" style="margin-top: 50px">
<div class="row">
<div class="col col-lg-6 col-lg-offset-3">
<form class="form">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">First Name</div>
<input type="text" style="width: 300px;" class="form-control " placeholder="Amount">
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">Last Name</div>
<input type="text" style="width: 300px;" class="form-control " placeholder="Amount">
</div>
</div>
<a class="btn btn-primary savebtn">保存</a>
</form>
</div>
</div>
<div class="row">
<div class="col col-lg-6 col-lg-offset-3">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Opration</th>
</tr>
</thead>
<tbody>
<tr>
<th>1</th>
<td>Mark</td>
<td>Otto</td>
<td><a class="btn btn-danger deletebtn btn-sm">删除</a>
</td>
</tr>
<tr>
<th>2</th>
<td>Jacob</td>
<td>Thornton</td>
<td><a class="btn btn-danger deletebtn btn-sm">删除</a>
</td>
</tr>
<tr>
<th>3</th>
<td>Larry</td>
<td>the Bird</td>
<td><a class="btn btn-danger deletebtn btn-sm">删除</a>
</td>
</tr>
<tr>
<th>3</th>
<td>Larry</td>
<td>the Bird</td>
<td><a class="btn btn-danger deletebtn btn-sm">删除</a>
</td>
</tr>
<tr>
<th>3</th>
<td>Larry</td>
<td>the Bird</td>
<td><a class="btn btn-danger deletebtn btn-sm">删除</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>