回答編集履歴

1

追記

2019/04/19 03:28

投稿

yambejp
yambejp

スコア117682

test CHANGED
@@ -5,3 +5,71 @@
5
5
  ```
6
6
 
7
7
  ってことですか?
8
+
9
+
10
+
11
+ # sample
12
+
13
+ - allをcontentsの中に流し込むならこう
14
+
15
+ ```javascript
16
+
17
+ <script>
18
+
19
+ window.addEventListener('DOMContentLoaded', function(e){
20
+
21
+ var all = document.querySelector("#all");
22
+
23
+ var contents= document.querySelector("#contents");
24
+
25
+ contents.appendChild(all);
26
+
27
+ });
28
+
29
+ </script>
30
+
31
+ <div id = "all">
32
+
33
+ <p>hogehogehogehogehogehogehogehogehogehogehogehogehogehoge</p>
34
+
35
+ <p>hogehogehogehogehogehogehogehogehogehogehogehogehogehoge</p>
36
+
37
+ <p>hogehogehogehogehogehogehogehogehogehogehogehogehogehoge</p>
38
+
39
+ </div>
40
+
41
+ <div id = "contents">fugafugafugafugafugafugafugafugafugafugafugafugafugafuga</div>
42
+
43
+ ```
44
+
45
+ - allをcontentsの後ろに移動するならこう
46
+
47
+ ```javascript
48
+
49
+ <script>
50
+
51
+ window.addEventListener('DOMContentLoaded', function(e){
52
+
53
+ var all = document.querySelector("#all");
54
+
55
+ var contents= document.querySelector("#contents");
56
+
57
+ contents.parentNode.insertBefore(all,contents.nextSibling);
58
+
59
+ });
60
+
61
+ </script>
62
+
63
+ <div id = "all">
64
+
65
+ <p>hogehogehogehogehogehogehogehogehogehogehogehogehogehoge</p>
66
+
67
+ <p>hogehogehogehogehogehogehogehogehogehogehogehogehogehoge</p>
68
+
69
+ <p>hogehogehogehogehogehogehogehogehogehogehogehogehogehoge</p>
70
+
71
+ </div>
72
+
73
+ <div id = "contents">fugafugafugafugafugafugafugafugafugafugafugafugafugafuga</div>
74
+
75
+ ```