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

6th Apr 2021, 4:44 AM
Wai Lim
Wai Lim - avatar
3 RĂ©ponses
+ 3
https://code.sololearn.com/W7ezxLC27lJo/?ref=app
6th Apr 2021, 5:01 AM
durian
durian - avatar
+ 1
How it work? Can you explain more?
6th Apr 2021, 8:18 AM
Wai Lim
Wai Lim - avatar
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)
6th Apr 2021, 8:58 AM
durian
durian - avatar