質問編集履歴

1

追記しました

2020/02/03 07:44

投稿

Poteto143
Poteto143

スコア32

test CHANGED
File without changes
test CHANGED
@@ -31,3 +31,35 @@
31
31
  <body>
32
32
 
33
33
  ```
34
+
35
+
36
+
37
+ ###追記
38
+
39
+ `<div id="sidebar">`内の`<h2>`タグと`</h2>`タグをそれぞれ`<p>`と`</p>`に置き換えようとしています。
40
+
41
+ 実行結果のイメージは以下の通りです。
42
+
43
+
44
+
45
+ ```html
46
+
47
+ <body>
48
+
49
+ <div id="sidebar">
50
+
51
+ <p>hoge</p> <!--置き換わる-->
52
+
53
+ <p>huga</p>
54
+
55
+ <p>piyo</p>
56
+
57
+ </div>
58
+
59
+ <body>
60
+
61
+ ```
62
+
63
+
64
+
65
+ これについて調べたところ、`replaceWith()`を使うという結果が出ましたが、一組のタグとその中身しか変えられないようでした。