回答編集履歴

2

調整

2021/10/12 02:48

投稿

yambejp
yambejp

スコア116835

test CHANGED
@@ -12,25 +12,47 @@
12
12
 
13
13
  br.classList.add('blank');
14
14
 
15
- [...document.querySelectorAll('body,body *')].map(x=>[...x.childNodes].filter(x=>x.nodeType==3)).flat().forEach(x=>{
15
+ [...document.querySelectorAll('body,body *')]
16
16
 
17
- x.nodeValue.split(/\n/).forEach((y,z)=>{
17
+ .map(x=>[...x.childNodes].filter(x=>x.nodeType==3))
18
18
 
19
- if(z>0) x.parentNode.insertBefore(br.cloneNode(true),x);
19
+ .flat()
20
20
 
21
- x.parentNode.insertBefore(document.createTextNode(y),x);
21
+ .forEach(x=>{
22
22
 
23
- });
23
+ x.nodeValue.split(/\n/).forEach((y,z)=>{
24
24
 
25
- x.remove();
25
+ if(z>0) x.parentNode.insertBefore(br.cloneNode(true),x);
26
26
 
27
+ x.parentNode.insertBefore(document.createTextNode(y),x);
28
+
27
- });
29
+ });
30
+
31
+ x.remove();
32
+
33
+ });
28
34
 
29
35
  });
30
36
 
31
37
  </script>
32
38
 
39
+ <body>
40
+
41
+ test
42
+
43
+ test
44
+
45
+ test
46
+
47
+ <span>
48
+
49
+
50
+
51
+
52
+
53
+ </span>
54
+
33
- <body>test
55
+ <span>test
34
56
 
35
57
  test
36
58
 
@@ -42,11 +64,7 @@
42
64
 
43
65
  test
44
66
 
45
- <span>test
46
-
47
- test
48
-
49
- test</span>
67
+ </span>
50
68
 
51
69
  </span>
52
70
 

1

調整

2021/10/12 02:48

投稿

yambejp
yambejp

スコア116835

test CHANGED
@@ -40,9 +40,9 @@
40
40
 
41
41
  test
42
42
 
43
- test<span>
43
+ test
44
44
 
45
- test
45
+ <span>test
46
46
 
47
47
  test
48
48