回答編集履歴

3

chousei

2024/10/28 02:39

投稿

yambejp
yambejp

スコア116627

test CHANGED
@@ -25,7 +25,7 @@
25
25
  }
26
26
  words.forEach((word) => {
27
27
  let tr = document.createElement('tr');
28
- tr.innerHTML += word.showInfo();
28
+ tr.innerHTML = word.showInfo();
29
29
  tbody.appendChild(tr);
30
30
  });
31
31
  total.textContent = `全${words.length}件`;

2

chousei

2024/10/28 02:38

投稿

yambejp
yambejp

スコア116627

test CHANGED
@@ -22,7 +22,6 @@
22
22
  tbody.innerHTML = '';;
23
23
  if(words.length==0){
24
24
  tbody.innerHTML = '<tr><td colspan=2 id="class">BASIC 300</td></tr>';;
25
- console.log(111);
26
25
  }
27
26
  words.forEach((word) => {
28
27
  let tr = document.createElement('tr');

1

調整

2024/10/28 01:52

投稿

yambejp
yambejp

スコア116627

test CHANGED
@@ -18,12 +18,16 @@
18
18
  <script>
19
19
  'use strict';
20
20
  function updateTable(words=[]) {
21
- table.innerHTML = '<tr><th>単語</th><th>意味</th></tr>';
21
+ const tbody=table.querySelector('tbody');
22
+ tbody.innerHTML = '';;
23
+ if(words.length==0){
22
- if(words.length==0) table.innerHTML += '<tr><td colspan=2 id="class">BASIC 300</td></tr>';
24
+ tbody.innerHTML = '<tr><td colspan=2 id="class">BASIC 300</td></tr>';;
25
+ console.log(111);
26
+ }
23
27
  words.forEach((word) => {
24
28
  let tr = document.createElement('tr');
25
- tr.innerHTML = word.showInfo();
29
+ tr.innerHTML += word.showInfo();
26
- table.appendChild(tr);
30
+ tbody.appendChild(tr);
27
31
  });
28
32
  total.textContent = `全${words.length}件`;
29
33
  }
@@ -68,19 +72,21 @@
68
72
  });
69
73
  </script>
70
74
 
71
- <h1>プログラミング必須英単語600+</h1>
75
+ <h1>プログラミング必須英単語600+</h1>
72
- <input type="text" placeholder="単語">
76
+ <input type="text" placeholder="単語">
73
- <input type="text" placeholder="意味">
77
+ <input type="text" placeholder="意味">
74
- <button id="btn">登録</button>
78
+ <button id="btn">登録</button>
75
- <p id="total">全0件</p>
79
+ <p id="total">全0件</p>
76
- <table id="table">
80
+ <table id="table">
81
+ <thead>
77
- <tr>
82
+ <tr>
78
- <th>単語</th>
83
+ <th>単語</th>
79
- <th>意味</th>
84
+ <th>意味</th>
80
- </tr>
85
+ </tr>
81
- <tr>
82
- <td colspan=2 id="class">BASIC 300</td>
83
- </tr>
86
+ </thead>
87
+ <tbody>
88
+ </tbody>
84
- </table>
89
+ </table>
85
90
  <button id="remove">remove</button>
86
91
  ```
92
+ ※一部調整