Inside the btnAdd.click() function , list item contains the last li element created and appended to the ulTasks.
Then how the function listItem.click() is called on any li item
Click event on listItem
Inside btnAdd.click, every time a new list item is generated and appended to the ulTasks
along with that, we are also calling the click event on listitem itself, so every list item has a binded click event that works when it is being clicked
this property is called closure, you can read more about it here
https://www.tutorialsteacher.com/javascript/closure-in-javascript
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.