how to make my delete function/button work in javascript (todo list project)
Hello, for some reason i cant get my delete function to work. I need to delete each list anytime the delete button is clicked but the delete function doesn’t even register the button clicked. I’ve done everything possible but nothing is working.
The add list function is the “addBtn” function.
The delete function is the “iconBtn” function.
I’ve tried putting the iconBtn function inside and outside the addBtn function but it still doesnt log the “button clicked” to the console like I specified
Please help. I added the codepen below.
CODE:
https://codepen.io/Godswill-Obi-ndaji/pen/oNJYwmQ
6 Replies
#how-to-ask-good-questions
Alrigh, how do I rephrase?
Well, if you have not read the link thread you can start there.
If you did, you can first put all the code you've put in the post in a codepen.io https://pen.new/
The iconBtn eventListener is not registering because it’s inside another event listener which is the addBtn event listener. Move it outside.
The event will only register when you click the addBtn. Click the addBtn and then click the iconBtn , you will see the log to the console. So you need to move it outside that function.
Thanks, i’ve edited it and done that.
https://codepen.io/Godswill-Obi-ndaji/pen/oNJYwmQ
Oh i’ve tried that. I’ve tried putting it both outside and inside the addBtn, still doesnt work.
The codepen: https://codepen.io/Godswill-Obi-ndaji/pen/oNJYwmQ