@@ -16,9 +16,10 @@ const db = getFirestore(app);
1616
1717const todoHandler = document . getElementById ( 'addTodoBtn' ) ;
1818const todoInput = document . getElementById ( 'todoInput' ) ;
19- const todoList = document . getElementById ( 'todoList' ) ;
20- const li = document . createElement ( 'li' )
21- li . className = "todo-item"
19+ const main = document . getElementById ( 'main' ) ;
20+ const ul = document . createElement ( 'ul' )
21+ ul . className = "todo-list"
22+ ul . id = "todoList"
2223
2324
2425todoHandler . addEventListener ( 'click' , async ( ) => {
@@ -44,7 +45,7 @@ todoHandler.addEventListener('click', async () => {
4445async function fetching ( ) {
4546 try {
4647 const querySnapshot = await getDocs ( collection ( db , 'Todo' ) ) ;
47- todoList . innerHTML = ""
48+ main . innerHTML = ""
4849 querySnapshot . forEach ( ( doc ) => {
4950 const getId = doc . data ( ) . id
5051 const getTodo = doc . data ( ) . todo
@@ -59,21 +60,16 @@ async function fetching() {
5960
6061function append ( id , todo ) {
6162 todoInput . value = ""
62- li . innerHTML += `
63+ ul . innerHTML += `
64+ <li class="todo-item">
6365 <input id="${ id } " class="inp" value=${ todo } type="text" readonly>
64- <button id="${ id } " onclick="edit(this)" class="btn-edit">Edit</button>
66+ <button id="${ id } " class="btn-edit">Edit</button>
6567 <button id="${ id } " class="btn-delete">Delete</button>
68+ </li>
6669 `
67- todoList . appendChild ( li )
70+ main . appendChild ( ul )
6871 console . log ( todoList ) ;
6972
7073}
7174
72- function edit ( button ) {
73- // const getClass = document.querySelector('.btn-edit')
74- // console.log(getClass);
75- console . log ( button ) ;
76-
77- }
78-
7975window . addEventListener ( "DOMContentLoaded" , fetching )
0 commit comments