質問編集履歴
3
書式の改善。
test
CHANGED
File without changes
|
test
CHANGED
@@ -243,3 +243,145 @@
|
|
243
243
|
}
|
244
244
|
|
245
245
|
```
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
以下、修正しました。
|
250
|
+
|
251
|
+
付番について解決できました。
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
ただ、「id_text.value」としたのですが、フォームに入力したテキストが出力されないのはなぜなのでしょうか?
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
```HTML
|
262
|
+
|
263
|
+
<!DOCTYPE html>
|
264
|
+
|
265
|
+
<html lang="ja">
|
266
|
+
|
267
|
+
<head>
|
268
|
+
|
269
|
+
<meta charset="UTF-8">
|
270
|
+
|
271
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
272
|
+
|
273
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
274
|
+
|
275
|
+
<title>ToDoリスト</title>
|
276
|
+
|
277
|
+
<link rel="stylesheet" href="css/styles.css">
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
</head>
|
282
|
+
|
283
|
+
<body>
|
284
|
+
|
285
|
+
<h1>ToDoリスト</h1>
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
<div class="radiobutton">
|
290
|
+
|
291
|
+
<input type="radio" id="button-1" name="radio1" value="1" checked />
|
292
|
+
|
293
|
+
<label for="button-1">すべて</label>
|
294
|
+
|
295
|
+
<input type="radio" id="button-2" name="radio1" value="2" />
|
296
|
+
|
297
|
+
<label for="button-2">完了中</label>
|
298
|
+
|
299
|
+
<input type="radio" id="button-3" name="radio1" value="3" />
|
300
|
+
|
301
|
+
<label for="button-3">作業中</label>
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
<h3 id="id_h3">ID コメント 状態</h3>
|
308
|
+
|
309
|
+
<div id="todo"></div>
|
310
|
+
|
311
|
+
<h2>新規タスクの増加</h2>
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
<p id = id_p>
|
316
|
+
|
317
|
+
<input type="text" id="id_text" value="">
|
318
|
+
|
319
|
+
<button id="btn" type="btn" class="button"> 追加</button>
|
320
|
+
|
321
|
+
</p>
|
322
|
+
|
323
|
+
</div>
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
<script>
|
328
|
+
|
329
|
+
let id = 0;
|
330
|
+
|
331
|
+
const btn = document.getElementById('btn');
|
332
|
+
|
333
|
+
btn.addEventListener('click', () => {
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
const idEl = document.createElement("span");
|
338
|
+
|
339
|
+
idEl.textContent = id;
|
340
|
+
|
341
|
+
const comment = document.getElementById(id_text.value);
|
342
|
+
|
343
|
+
const commentEl = document.createElement("span");
|
344
|
+
|
345
|
+
commentEl.textContent = (comment);
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
const btn1El = document.createElement("button");
|
350
|
+
|
351
|
+
btn1El.textContent = "作業中";
|
352
|
+
|
353
|
+
const btn2El = document.createElement("button");
|
354
|
+
|
355
|
+
btn2El.textContent = "削除";
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
const divEl = document.createElement("div");
|
360
|
+
|
361
|
+
divEl.appendChild(idEl);
|
362
|
+
|
363
|
+
divEl.appendChild(commentEl);
|
364
|
+
|
365
|
+
divEl.appendChild(btn1El);
|
366
|
+
|
367
|
+
divEl.appendChild(btn2El);
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
const todoEl = document.getElementById("todo");
|
372
|
+
|
373
|
+
todoEl.appendChild(divEl);
|
374
|
+
|
375
|
+
id++;
|
376
|
+
|
377
|
+
}, false);
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
</script>
|
382
|
+
|
383
|
+
</body>
|
384
|
+
|
385
|
+
</html>
|
386
|
+
|
387
|
+
```
|
2
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,7 +20,9 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
+
|
24
|
+
|
23
|
-
```
|
25
|
+
```HTML
|
24
26
|
|
25
27
|
<!DOCTYPE html>
|
26
28
|
|
@@ -147,3 +149,97 @@
|
|
147
149
|
</html>
|
148
150
|
|
149
151
|
```
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
```CSS
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
.button {
|
160
|
+
|
161
|
+
border-radius: 10px;
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
.button:hover {
|
166
|
+
|
167
|
+
background-color: #59b1eb;
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
.button:active {
|
172
|
+
|
173
|
+
top: 3px;
|
174
|
+
|
175
|
+
box-shadow: none;
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
.radiobutton label {
|
184
|
+
|
185
|
+
padding: 0 0 0 24px; /* ラベルの位置 */
|
186
|
+
|
187
|
+
font-size: 16px;
|
188
|
+
|
189
|
+
line-height: 28px; /* ボタンのサイズに合わせる */
|
190
|
+
|
191
|
+
display: inline-block;
|
192
|
+
|
193
|
+
cursor: pointer;
|
194
|
+
|
195
|
+
position: relative;
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
.radiobutton label:before {
|
200
|
+
|
201
|
+
content: '';
|
202
|
+
|
203
|
+
width: 14px; /* ボタンの横幅 */
|
204
|
+
|
205
|
+
height: 14px; /* ボタンの縦幅 */
|
206
|
+
|
207
|
+
position: absolute;
|
208
|
+
|
209
|
+
top: 0;
|
210
|
+
|
211
|
+
left: 0;
|
212
|
+
|
213
|
+
background-color: rgb(0, 162, 255);
|
214
|
+
|
215
|
+
border-radius: 50%;
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
.radiobutton input[type="radio"] {
|
220
|
+
|
221
|
+
display: none;
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
.radiobutton input[type="radio"]:checked + label:after {
|
226
|
+
|
227
|
+
content: '';
|
228
|
+
|
229
|
+
width: 3px; /* マークの横幅 */
|
230
|
+
|
231
|
+
height: 3px; /* マークの縦幅 */
|
232
|
+
|
233
|
+
position: absolute;
|
234
|
+
|
235
|
+
top: 5.5px;
|
236
|
+
|
237
|
+
left: 5.5px;
|
238
|
+
|
239
|
+
background-color: #fff;
|
240
|
+
|
241
|
+
border-radius: 50%;
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
```
|
1
書式の改善。
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
フォームに入力したテキスト
|
1
|
+
フォームに入力したテキストを反映させたい
|
test
CHANGED
@@ -1,14 +1,20 @@
|
|
1
|
-
|
1
|
+
[課題](https://gyazo.com/d2c1c87a05c786e2ded8873d13fd0a0d)
|
2
2
|
|
3
|
-
|
3
|
+
上記の課題を作っている最中です。
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
|
7
|
+
現在の状態が以下の画像の通りです。
|
8
8
|
|
9
|
-
|
9
|
+
![現在の状態](72c4ae4160adb78c1397c0c27a72939f.png)
|
10
10
|
|
11
11
|
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
追加ボタンを押したときに、「0」と作業中の間にフォームに入力したテキストを反映したいのですが、反映されません。
|
16
|
+
|
17
|
+
反映されない理由は「commentEl.textContent = comment;」で文章(テキスト)しか取れないのにもかかわらず、textContentを使っているから反映されないのかと思うのですが、どう改善すればいいのかが分かりません。
|
12
18
|
|
13
19
|
|
14
20
|
|