@@ -220,17 +220,7 @@ addButton.onclick = () => {
220220 todoInput .value = " " ;
221221 editButton .textContent = " 編集" ;
222222 editButton .onclick = () => {
223- const input = document .createElement (" input" );
224- const confirmButton = document .createElement (" button" );
225- input .value = todoText .textContent ;
226- confirmButton .textContent = " 確定" ;
227- confirmButton .onclick = () => {
228- todoText .textContent = input .value ;
229- todoItem .replaceChild (todoText, input);
230- todoItem .replaceChild (editButton, confirmButton);
231- };
232- todoItem .replaceChild (input, todoText);
233- todoItem .replaceChild (confirmButton, editButton);
223+ todoText .textContent = prompt (" 編集内容を入力してください" );
234224 };
235225 deleteButton .textContent = " 削除" ;
236226 deleteButton .onclick = () => {
@@ -285,12 +275,10 @@ todoInput.oninput = () => {
285275const todoList = document .getElementById (" todo-list" );
286276const todoInput = document .getElementById (" todo-input" );
287277const addButton = document .getElementById (" add-button" );
288- todoInput .oninput = () => {
289- addButton .disabled = todoInput .value === " " ;
290- };
278+
279+ todoInput .oninput = () => (addButton .disabled = todoInput === " " );
291280
292281addButton .onclick = () => {
293- addButton .disabled = true ;
294282 const todoItem = document .createElement (" li" );
295283 const todoText = document .createElement (" span" );
296284 const editButton = document .createElement (" button" );
@@ -299,20 +287,8 @@ addButton.onclick = () => {
299287 todoInput .value = " " ;
300288 editButton .textContent = " 編集" ;
301289 editButton .onclick = () => {
302- const input = document .createElement (" input" );
303- const confirmButton = document .createElement (" button" );
304- input .value = todoText .textContent ;
305- input .oninput = () => {
306- confirmButton .disabled = input .value === " " ;
307- };
308- confirmButton .textContent = " 確定" ;
309- confirmButton .onclick = () => {
310- todoText .textContent = input .value ;
311- todoItem .replaceChild (todoText, input);
312- todoItem .replaceChild (editButton, confirmButton);
313- };
314- todoItem .replaceChild (input, todoText);
315- todoItem .replaceChild (confirmButton, editButton);
290+ const input = prompt (" 編集内容を入力してください" );
291+ if (input !== " " ) todoText .textContent = input;
316292 };
317293 deleteButton .textContent = " 削除" ;
318294 deleteButton .onclick = () => {
0 commit comments