0
Question on making to do list
Hey guys, I made two to do list using JS code but I am confused about how to remove the listed item. I donât have any idea about this. In the first to do list, I can only remove the top one , I know the reason because querySelector only target the first element but I want to remove the specific list item. Beside, in the second to do list , I want to ask why the code in line 10-11 can avoid duplicate when I add new items. This two line of code is copied from the internet, I know what it does but donât know how it works, can somebody explain it to me??? Thank Youđđ»ââïž https://code.sololearn.com/WYg584q9yAGg/?ref=app https://code.sololearn.com/WHEHPFCSvatv/?ref=app
3 RĂ©ponses
+ 3
https://code.sololearn.com/W7ezxLC27lJo/?ref=app
+ 1
How it work? Can you explain more?
0
i just use 'this' keyword to find out which element is clicked..
note that 'this' will return the button element, so i get the parentnode(li element) and assign it to removeItem variable
also notice that i changed setAttribute("click", "func") to onclick, cause 'this' keyword in setAttribute seems to not bind the element(idk why though)