Now you can load your to-do list and add items to it, but what's the point if you can't check them off when you've done them? Next up, you're going to do just that, and it'll be pretty easy. First, you need to connect double-clicking on a list item (
litag) to yourtoggleToDoItemStatefunction. You can do this by having JavaScript listen for double-clicking onlitags and running a function that calls yourtoggleToDoItemStatefunction. It looks like this:document.getElementById("todo").addEventListener("dblclick",function(event){ if(event.target && event.target.matches("li")){ toggleToDoItemState(event.target) } })What's happening here is:
- JavaScript is listening to all double-clicks that happen on the 
todolist - If it “hears” one, it runs a function, into which it passes the details of the click 
event - If the 
eventhad atarget(a thing that was clicked on) and thattargetmatches"li", which is the HTML tag for a list item then:- Run 
toggleToDoItemStateand pass it theevent.targetinformation 
 - Run 
 
- JavaScript is listening to all double-clicks that happen on the 
 Next, you need to update your
toggleToDoItemStatefunction so it adds thecompletedclass (a HTML property—a tag, like<li>can have many classes) to the item that was double-clicked, which will put a line through it using some of my CSS code. Thankfully, in modern JavaScript, that's pretty simple! Just update this totoggleToDoItemState:function toggleToDoItemState(target){ target.classList.toggle("completed") }