Solution Review: Deleting a Task from the To-Do List
This review provides a detailed explanation to solve the 'Deleting a Task from the To-Do List' challenge.
We'll cover the following
Solution
Explanation
-
In line 2, we assign a click event handler to the delete button, a descendant of
div
withid
equal todelete
. We use theon()
method here because the delete button is dynamically created and the direct method$("#delete").click()
won’t work. -
In line 3, we extract the parent of the delete button, which is the task to be deleted.
-
In line 4, we delete that extracted parent element using the
remove()
method.