Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- Persistent store Coordinator
- 1009번
- 트레일링 클로저
- dateFormatter
- 스위프트 클로저
- codability
- LightWeight Migration
- Raw value and Associated value
- iOS Static Library 사용하는방법
- Swift LinkedList
- leetcode #01
- NSSortDescriptor
- Swift 고차함수
- CoreData
- CoreData Stack
- expensive operation
- NSManagedObject SubClass
- iOS Static Library
- CoreData Filter
- Java
- 다익스트라 이해
- 2022 부스트캠프
- Swift
- CoreData Concurrency
- Associated Value
- Clean swift
- persistentStoreCoordinator
- Swift closure
- NSPredicates
- 일급 객체
Archives
- Today
- Total
하루를살자
JS Clone Project [to-do list] - 1,2 본문
The following code will cover generating a to-do list and delete button.
- todo.js
const todoForm = document.querySelector("#todo-form");
const todoList = document.querySelector("#todo-list");
const todoInput = document.querySelector("#todo-form input");
// const list_key = "userList"; //Will be used later on
//3. Delete selected todo list
function deleteTodo(event){
//We can identify which li called this event by inspecting event.target object.
console.log(event.target);
console.dir(event.target.parentElement.innerText);
//I designate the selected li element
const li = event.target.parentElement;
//Remove the list
li.remove();
}
//2. Creating HTML element
function paintToDo(newTodo){
//Desired structure of HTML is
// <li>
// <span> lalalal </span>
// <button> X </button>
//</li>
const list = document.createElement("li");
const span = document.createElement("span");
span.innerHTML = newTodo;
const button = document.createElement("button");
button.innerHTML = "X";
//Calls for deleteing selected toDo list function
button.addEventListener("click", deleteTodo);
list.appendChild(span);
list.appendChild(button);
todoList.appendChild(list);
}
- index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<title>Clone Momentum App</title>
</head>
<body>
<form id ="login-form" class = "hidden">
<input required maxlength="15" type ="text" placeholder=" What is your name?"/>
<button> Log In </button>
</form>
<h1 id = "greeting" class = "hidden"> </h1>
<form id = "todo-form">
<input type = "text" placeholder="Write a To Do and Press Enter" required>
</form>
<ul id = "todo-list">
</ul>
<h2 id ="clock"></h2>
<div id ="quote">
<span > </span>
<span > </span>
</div>
<script src = "js/quotes.js"></script>
<script src = "js/greeting.js"></script>
<script src = "js/clock.js"></script>
<script src = "js/background.js"></script>
<script src = "js/todo.js"></script>
</body>
</html>
--> Added :
1. form for "todo-form"
2. ul for "todo-list"
'JS' 카테고리의 다른 글
JS Clone Project [to-do list] - 4, Deleting to-Do list (0) | 2021.12.09 |
---|---|
JS Clone Project [to-do list] - 3, Saving to-do list (0) | 2021.12.09 |
JS Clone Project [Background] (0) | 2021.12.05 |
JS Clone Project [Quotes] (0) | 2021.12.05 |
JS Clone Project [Clock] - 2, PadStart (0) | 2021.12.05 |
Comments