回答編集履歴
1
sample
test
CHANGED
@@ -1 +1,99 @@
|
|
1
1
|
cloneしてお互いのいらない行を削除すればよいでしょう
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
# sample
|
6
|
+
|
7
|
+
```javascript
|
8
|
+
|
9
|
+
<script>
|
10
|
+
|
11
|
+
window.addEventListener('DOMContentLoaded', function(e){
|
12
|
+
|
13
|
+
var t1=document.querySelector('table');
|
14
|
+
|
15
|
+
var t2=t1.cloneNode(true);
|
16
|
+
|
17
|
+
var idx=2;
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
[].forEach.call(t1.querySelectorAll('tbody tr'),function(x,y){
|
22
|
+
|
23
|
+
if(y>=idx) x.parentNode.removeChild(x);
|
24
|
+
|
25
|
+
});
|
26
|
+
|
27
|
+
[].forEach.call(t2.querySelectorAll('tbody tr'),function(x,y){
|
28
|
+
|
29
|
+
if(y<idx) x.parentNode.removeChild(x);
|
30
|
+
|
31
|
+
});
|
32
|
+
|
33
|
+
t1.parentNode.appendChild(t2);
|
34
|
+
|
35
|
+
});
|
36
|
+
|
37
|
+
</script>
|
38
|
+
|
39
|
+
<table style="table-layout: fixed" border>
|
40
|
+
|
41
|
+
<thead>
|
42
|
+
|
43
|
+
<tr>
|
44
|
+
|
45
|
+
<th>見出し-1</th>
|
46
|
+
|
47
|
+
<th>見出し-2</th>
|
48
|
+
|
49
|
+
</tr>
|
50
|
+
|
51
|
+
</thead>
|
52
|
+
|
53
|
+
<tbody>
|
54
|
+
|
55
|
+
<tr>
|
56
|
+
|
57
|
+
<td>行1-1</td>
|
58
|
+
|
59
|
+
<td>行1-2</td>
|
60
|
+
|
61
|
+
</tr>
|
62
|
+
|
63
|
+
<tr>
|
64
|
+
|
65
|
+
<td>行2-1</td>
|
66
|
+
|
67
|
+
<td>行2-2</td>
|
68
|
+
|
69
|
+
</tr>
|
70
|
+
|
71
|
+
<tr>
|
72
|
+
|
73
|
+
<td>行3-1</td>
|
74
|
+
|
75
|
+
<td>行3-2</td>
|
76
|
+
|
77
|
+
</tr>
|
78
|
+
|
79
|
+
<tr>
|
80
|
+
|
81
|
+
<td>行4-1</td>
|
82
|
+
|
83
|
+
<td>行4-2</td>
|
84
|
+
|
85
|
+
</tr>
|
86
|
+
|
87
|
+
<tr>
|
88
|
+
|
89
|
+
<td>行5-1</td>
|
90
|
+
|
91
|
+
<td>行5-2</td>
|
92
|
+
|
93
|
+
</tr>
|
94
|
+
|
95
|
+
</tbody>
|
96
|
+
|
97
|
+
</table>
|
98
|
+
|
99
|
+
```
|