@@ -18,6 +18,7 @@ const todoHandler = document.getElementById('addTodoBtn');
1818const todoInput = document . getElementById ( 'todoInput' ) ;
1919const todoList = document . getElementById ( 'todoList' ) ;
2020const li = document . createElement ( 'li' )
21+ li . className = "todo-item"
2122
2223
2324todoHandler . addEventListener ( 'click' , async ( ) => {
@@ -48,6 +49,7 @@ async function fetching() {
4849 const getId = doc . data ( ) . id
4950 const getTodo = doc . data ( ) . todo
5051 append ( getId , getTodo )
52+ // edit(getId, getTodo)
5153 } ) ;
5254 } catch ( error ) {
5355 console . log ( 'The error is in getDocs ::' , error ) ;
@@ -58,14 +60,19 @@ async function fetching() {
5860function append ( id , todo ) {
5961 todoInput . value = ""
6062 li . innerHTML += `
61- <li class="todo-item">
62- <input id=${ id } class="inp" value=${ todo } type="text" readonly>
63- <button id=${ id } class="btn-edit">Edit</button>
64- <button id=${ id } class="btn-delete">Delete</button>
65- </li>
63+ <input id="${ id } " class="inp" value=${ todo } type="text" readonly>
64+ <button id="${ id } " onclick="edit(this)" class="btn-edit">Edit</button>
65+ <button id="${ id } " class="btn-delete">Delete</button>
6666 `
6767 todoList . appendChild ( li )
6868 console . log ( todoList ) ;
69+
70+ }
71+
72+ function edit ( button ) {
73+ // const getClass = document.querySelector('.btn-edit')
74+ // console.log(getClass);
75+ console . log ( button ) ;
6976
7077}
7178
0 commit comments