質問編集履歴
5
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -295,3 +295,293 @@
|
|
295
295
|
|
296
296
|
|
297
297
|
```
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
##編集後のコード
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
```ここに言語を入力
|
306
|
+
|
307
|
+
<!DOCTYPE html>
|
308
|
+
|
309
|
+
<html lang="ja">
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
<head>
|
316
|
+
|
317
|
+
<meta charset="UTF-8">
|
318
|
+
|
319
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
320
|
+
|
321
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
322
|
+
|
323
|
+
<title>ToDoリスト</title>
|
324
|
+
|
325
|
+
<link rel="stylesheet" href="css/style.css">
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
</head>
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
<body>
|
336
|
+
|
337
|
+
<h1>ToDoリスト</h1>
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
<div class="radiobutton">
|
342
|
+
|
343
|
+
<input type="radio" id="filter-all" name="radio1" value="1" checked="checked" />
|
344
|
+
|
345
|
+
<label for="filter-all">すべて</label>
|
346
|
+
|
347
|
+
<input type="radio" id="filter-done" name="radio1" value="2" />
|
348
|
+
|
349
|
+
<label for="filter-done">完了中</label>
|
350
|
+
|
351
|
+
<input type="radio" id="filter-working" name="radio1" value="3" />
|
352
|
+
|
353
|
+
<label for="filter-working">作業中</label>
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
<table>
|
358
|
+
|
359
|
+
<thead id>
|
360
|
+
|
361
|
+
<tr>
|
362
|
+
|
363
|
+
<th>ID</th>
|
364
|
+
|
365
|
+
<th>コメント</th>
|
366
|
+
|
367
|
+
<th>状態</th>
|
368
|
+
|
369
|
+
</tr>
|
370
|
+
|
371
|
+
</thead>
|
372
|
+
|
373
|
+
<tbody id="idTbody">
|
374
|
+
|
375
|
+
</tbody>
|
376
|
+
|
377
|
+
</table>
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
<h2>新規タスクの増加</h2>
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
<p id=todo-form>
|
386
|
+
|
387
|
+
<input type="text" id="todo-comment" value="">
|
388
|
+
|
389
|
+
<button id="btn" type="btn" class="button" value=""> 追加</button>
|
390
|
+
|
391
|
+
</p>
|
392
|
+
|
393
|
+
</div>
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
<script src="js/main.js"></script>
|
398
|
+
|
399
|
+
</body>
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
</html>
|
404
|
+
|
405
|
+
```
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
```ここに言語を入力
|
410
|
+
|
411
|
+
'use strict'
|
412
|
+
|
413
|
+
let taskid = 0;
|
414
|
+
|
415
|
+
function entryChange() {
|
416
|
+
|
417
|
+
radio = document.getElementsByName('radio1')
|
418
|
+
|
419
|
+
//ラジオボタンの0(すべて)がチェックされたとき
|
420
|
+
|
421
|
+
if (radio[0].checked) {
|
422
|
+
|
423
|
+
document.getElementsByClassName('done').style.display = "";
|
424
|
+
|
425
|
+
document.getElementsByClassName('doing').style.display = "";
|
426
|
+
|
427
|
+
//ラジオボタンの1(完了)がチェックされたとき
|
428
|
+
|
429
|
+
} else if (radio[1].checked) {
|
430
|
+
|
431
|
+
//フォーム
|
432
|
+
|
433
|
+
doing.forEach(done => {
|
434
|
+
|
435
|
+
console.log(done);
|
436
|
+
|
437
|
+
document.getElementsByClassName('done').styledisplay = "";
|
438
|
+
|
439
|
+
document.getElementsByClassName('doing').style.display = "none";
|
440
|
+
|
441
|
+
})
|
442
|
+
|
443
|
+
//ラジオボタンの2(作業中)がチェックされたとき
|
444
|
+
|
445
|
+
} else if (radio[2].checked) {
|
446
|
+
|
447
|
+
//フォーム
|
448
|
+
|
449
|
+
doing.forEach(work => {
|
450
|
+
|
451
|
+
console.log(work);
|
452
|
+
|
453
|
+
document.getElementsByClassName('done').style.display = "none";
|
454
|
+
|
455
|
+
document.getElementsByClassName('doing').style.display = "";
|
456
|
+
|
457
|
+
})
|
458
|
+
|
459
|
+
}
|
460
|
+
|
461
|
+
}
|
462
|
+
|
463
|
+
//オンロードさせ、リロード時に選択を保持
|
464
|
+
|
465
|
+
window.onload = entryChange;
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
//イベントリスナ―を登録
|
470
|
+
|
471
|
+
const add_btn = document.getElementById('btn');
|
472
|
+
|
473
|
+
add_btn.addEventListener('click', () => {
|
474
|
+
|
475
|
+
const id_td = document.createElement("td");
|
476
|
+
|
477
|
+
id_td.textContent = taskid;
|
478
|
+
|
479
|
+
const comment = document.getElementById("todo-comment").value;
|
480
|
+
|
481
|
+
const commentEl = document.createElement("td");
|
482
|
+
|
483
|
+
commentEl.textContent = (comment);
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
const createWorkingBtn = function () {
|
488
|
+
|
489
|
+
//作業中ボタンを生成する処理
|
490
|
+
|
491
|
+
const workingBtn = document.createElement("button");
|
492
|
+
|
493
|
+
workingBtn.classList.add("doing");
|
494
|
+
|
495
|
+
workingBtn.textContent = "作業中";
|
496
|
+
|
497
|
+
workingBtn.addEventListener('click', () => {
|
498
|
+
|
499
|
+
console.log('表示を変更');
|
500
|
+
|
501
|
+
if (workingBtn.textContent === "作業中") {
|
502
|
+
|
503
|
+
workingBtn.classList.add("doing");
|
504
|
+
|
505
|
+
workingBtn.textContent = "完了";
|
506
|
+
|
507
|
+
// ボタン押下で生成されたdomの中の親要素へclassNameをつける処理
|
508
|
+
|
509
|
+
const doneParent = workingBtn.parentNode;
|
510
|
+
|
511
|
+
doneParent.className = 'workDone';
|
512
|
+
|
513
|
+
} else {
|
514
|
+
|
515
|
+
workingBtn.classList.add("done");
|
516
|
+
|
517
|
+
workingBtn.textContent = "作業中";
|
518
|
+
|
519
|
+
// ボタン押下で生成されたdomの中の親要素へclassNameをつける処理
|
520
|
+
|
521
|
+
const workParent = this.parentNode;
|
522
|
+
|
523
|
+
workParent.className = 'work';
|
524
|
+
|
525
|
+
}
|
526
|
+
|
527
|
+
})
|
528
|
+
|
529
|
+
//生成した作業中ボタンを返す処理
|
530
|
+
|
531
|
+
return workingBtn;
|
532
|
+
|
533
|
+
}
|
534
|
+
|
535
|
+
const workingBtn = createWorkingBtn();
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
const createDelBtn = function () {
|
542
|
+
|
543
|
+
//削除ボタンを生成する処理
|
544
|
+
|
545
|
+
const delBtn = document.createElement("button");
|
546
|
+
|
547
|
+
delBtn.textContent = "削除";
|
548
|
+
|
549
|
+
delBtn.addEventListener('click', () => {
|
550
|
+
|
551
|
+
idTbody.removeChild(trEl);
|
552
|
+
|
553
|
+
})
|
554
|
+
|
555
|
+
//生成した削除ボタンを返す処理
|
556
|
+
|
557
|
+
return delBtn;
|
558
|
+
|
559
|
+
}
|
560
|
+
|
561
|
+
const delBtn = createDelBtn()
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
const trEl = document.createElement("tr");
|
566
|
+
|
567
|
+
trEl.appendChild(id_td);
|
568
|
+
|
569
|
+
trEl.appendChild(commentEl);
|
570
|
+
|
571
|
+
trEl.appendChild(workingBtn);
|
572
|
+
|
573
|
+
trEl.appendChild(delBtn);
|
574
|
+
|
575
|
+
const todoEl = document.getElementById("idTbody");
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
todoEl.appendChild(trEl);
|
580
|
+
|
581
|
+
taskid++;
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
}, false);
|
586
|
+
|
587
|
+
```
|
4
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
##質問の内容https://github.com/manaberuit/javascript_practice2/blob/master/README.md
|
1
|
+
##質問の内容 [課題内容](https://github.com/manaberuit/javascript_practice2/blob/master/README.md)
|
2
2
|
|
3
3
|
javaScriptでtodoListを作っています。
|
4
4
|
|
3
書式の改善。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
##質問の内容
|
1
|
+
##質問の内容https://github.com/manaberuit/javascript_practice2/blob/master/README.md
|
2
2
|
|
3
3
|
javaScriptでtodoListを作っています。
|
4
4
|
|
2
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -262,7 +262,7 @@
|
|
262
262
|
|
263
263
|
function entryChange1() {
|
264
264
|
|
265
|
-
|
265
|
+
const radio = document.getElementsByName('radio1')
|
266
266
|
|
267
267
|
if (radio[0].checked) {
|
268
268
|
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,6 +38,12 @@
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
+
以下、現在のコードです。
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
41
47
|
```
|
42
48
|
|
43
49
|
<!DOCTYPE html>
|