質問編集履歴

1

文法の修正。

2019/11/27 17:25

投稿

asako1010
asako1010

スコア50

test CHANGED
File without changes
test CHANGED
@@ -101,3 +101,93 @@
101
101
  </html>
102
102
 
103
103
  ```
104
+
105
+
106
+
107
+ h3を定義したところ、以下のエラーが出ました。
108
+
109
+ TypeError: Failed to execute 'insertBefore' on 'Node': parameter 1 is not of type 'Node'.
110
+
111
+
112
+
113
+ 「textの部分はNodeじゃないとダメ」という意味だと思うのですが、どう言い換えればいいのかが分かりません。
114
+
115
+
116
+
117
+ ```ここに言語を入力
118
+
119
+ <!DOCTYPE html>
120
+
121
+ <html lang="ja">
122
+
123
+ <head>
124
+
125
+ <meta charset="UTF-8">
126
+
127
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
128
+
129
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
130
+
131
+ <title>ToDoリスト</title>
132
+
133
+ <link rel="stylesheet" href="css/styles.css">
134
+
135
+ </head>
136
+
137
+ <body>
138
+
139
+ <h1>ToDoリスト</h1>
140
+
141
+ <label><input type="radio" name="phone">すべて</label>
142
+
143
+ <label><input type="radio" name="phone" >作業中</label>
144
+
145
+ <label><input type="radio" name="phone">完了中</label>
146
+
147
+ <h3 id="id_h3">IDコメント 状態</h3>
148
+
149
+ <h2>新規タスクの追加</h2>
150
+
151
+
152
+
153
+ <p>
154
+
155
+ <input type="text" id="id_text" value="">
156
+
157
+ <button id="btn" type="btn"> 追加</button>
158
+
159
+ </p>
160
+
161
+
162
+
163
+
164
+
165
+ <script>
166
+
167
+ const btn = document.getElementById('btn');
168
+
169
+ btn.addEventListener('click', () => {
170
+
171
+ const text = document.getElementById('id_text').value;
172
+
173
+ const h3 = document.getElementById('id_h3');
174
+
175
+
176
+
177
+
178
+
179
+ document.body.insertBefore(text, h3);
180
+
181
+ });
182
+
183
+
184
+
185
+ </script>
186
+
187
+
188
+
189
+ </body>
190
+
191
+ </html>
192
+
193
+ ```