Javascript to find the element?

I'm just starting to learn JS so please advice!
There is such code
this todo list. tell me how when clicking on the created item to add the property display: none.
my difficulty is that I cannot loop to iterate over elements are created javascrip - om and how to manipulate them!
July 2nd 19 at 17:11
2 answers
July 2nd 19 at 17:13
You just hang up event handlers on elements before they are created, i.e. you have first performed
var todoItem = document.querySelectorAll('.todo_item'); 
[], function (item) {
 item.addEventListener ....

And do elements with the class .todo_item are only generated after pressing the button. Accordingly, you need to add the click event handler to each element class .todo_item at the time of its creation.

PS: it is good practice not to change CSS properties from scripts (in your case the display: none), and make CSS classes and add them to the element or remove (e.g. to make a class .hide { display: none; } and add it to the elements).
thank you! realized the mistake! - Westley_Hane commented on July 2nd 19 at 17:16
July 2nd 19 at 17:15

Find more questions by tags JavaScript