回答編集履歴

2

追加

2022/06/17 02:03

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア35865

test CHANGED
@@ -92,3 +92,7 @@
92
92
  return temp.content.children;
93
93
  },
94
94
  ```
95
+
96
+ ```js
97
+ tr.append(...colors[i].showInfo());
98
+ ```

1

コメントを受けて追記

2022/06/17 02:02

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア35865

test CHANGED
@@ -70,3 +70,25 @@
70
70
 
71
71
   ステップ実行をするなどしてコードの実行順について理解を深めるのがいいかと思います。devtools の使い方は大丈夫ですか?
72
72
 
73
+ ---
74
+
75
+ ### コメントを受けて追記
76
+
77
+ ```js
78
+ showInfo() {
79
+ const temp = document.createElement('template');
80
+
81
+ temp.innerHTML = `<td>${this.en}</td><td>${this.ja}</td><td><button class="btn">削除</button></td>`;
82
+ const btn = temp.content.querySelector('.btn');
83
+ btn.addEventListener('click', e => {
84
+ // localStorage.removeItem(words[i][0]);
85
+ // localStorage.removeItem(words[i][1]);
86
+ if (window.confirm('本当に削除しますか?')) {
87
+ let parent = e.target.closest('tr');
88
+ parent.remove();
89
+ }
90
+ });
91
+
92
+ return temp.content.children;
93
+ },
94
+ ```