HTML Diff
0 added 0 removed
Original 2026-01-01
Modified 2026-03-09
1 <p>The event is triggered. It is time to change the console output to remove the completed task.</p>
1 <p>The event is triggered. It is time to change the console output to remove the completed task.</p>
2 <p>There are various ways of removing elements from the page, of which one of the simplest is calling the remove method on the element that needs to be removed.</p>
2 <p>There are various ways of removing elements from the page, of which one of the simplest is calling the remove method on the element that needs to be removed.</p>
3 element.remove();<p>The method in the example above removes the element from DOM.</p>
3 element.remove();<p>The method in the example above removes the element from DOM.</p>
4 <p>By the way, why did we use this function in particular and not add a handler to the element directly inside the loop? It all has to do with the scopes. We already discussed closures when we created the gallery<a>in this chapter</a>using events. If we placed the handler inside the loop, our program would not work correctly, because only the last element in the collection of elements would be deleted. If you forget why this behavior can happen, you can refresh your knowledge by first reviewing<a>this assignment</a>and then<a>this one</a>.</p>
4 <p>By the way, why did we use this function in particular and not add a handler to the element directly inside the loop? It all has to do with the scopes. We already discussed closures when we created the gallery<a>in this chapter</a>using events. If we placed the handler inside the loop, our program would not work correctly, because only the last element in the collection of elements would be deleted. If you forget why this behavior can happen, you can refresh your knowledge by first reviewing<a>this assignment</a>and then<a>this one</a>.</p>
5 <p>Use the remove method to remove the completed task in our app.</p>
5 <p>Use the remove method to remove the completed task in our app.</p>