From 1527082010385e4bdd501a782f16af2e78dbaf05 Mon Sep 17 00:00:00 2001 From: Mac_BaekMinJun Date: Wed, 11 Dec 2024 15:53:32 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EC=B4=88=EA=B8=89=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- greeting-script.js | 34 ++++++++++++++++++++++++++++++++++ simple.html | 43 +++++++++++++++++++++++-------------------- 2 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 greeting-script.js diff --git a/greeting-script.js b/greeting-script.js new file mode 100644 index 0000000..4a97baa --- /dev/null +++ b/greeting-script.js @@ -0,0 +1,34 @@ +function keyCodeCheck(){ + // 엔터키를 사용하거나, 빈 내용이 아니면 아래 코드를 실행 + if(window.event.keyCode === 13 && document.querySelector('.todo-input').value.trim() !== ''){ + // 생성하는 메서드 + addToDo(); + } +} + +function buttonCheck(){ + // 버튼클릭시 입력창의 요소가 빈 내용이 아니면 아래 코드를 실행 + if(document.querySelector('.todo-input').value.trim() !== ''){ + // 생성하는 메서드 + addToDo(); + } +} + +function addToDo(){ + const todoInput = document.querySelector('.todo-input'); + const todoList = document.querySelector('.todo-list'); + + if(confirm(`"${todoInput.value.trim()}" 저장하시겠습니까?`)){ + // li 요소 생성 + const newLi = document.createElement('li'); + + // 생성된 li 요소에 내용 추가 + newLi.textContent = todoInput.value; + + // todoList에 li요소 추가 + todoList.appendChild(newLi); + } + + // input값 초기화 + todoInput.value = ''; +} \ No newline at end of file diff --git a/simple.html b/simple.html index 2887e44..47b2c12 100644 --- a/simple.html +++ b/simple.html @@ -1,24 +1,27 @@ - - - + + + Simple TODO List - - -
-

TODO

-
- - -
-
-
    -
  • 밥 먹기
  • -
  • 2시 약속
  • -
-
+ + + +
+

TODO

+
+ + + + +
+
+
    +
  • 밥 먹기
  • +
  • 2시 약속
  • +
+
- - - + + + \ No newline at end of file From e52783a6723c92a9bb3412b14f675012f55d4031 Mon Sep 17 00:00:00 2001 From: Mac_BaekMinJun Date: Fri, 20 Dec 2024 23:12:54 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[add]=20=EC=A4=91=EA=B8=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- detail.html | 113 +++++++++++++++++++++++++++++++- simple.html | 3 +- greeting-script.js => simple.js | 0 3 files changed, 113 insertions(+), 3 deletions(-) rename greeting-script.js => simple.js (100%) diff --git a/detail.html b/detail.html index 160571b..3a3f91a 100644 --- a/detail.html +++ b/detail.html @@ -9,7 +9,7 @@

TODO LIST

- +