0

For loop doesn't stop

Why when I click the element li why confirm it appeared repeatedly? https://code.sololearn.com/WyvHCv6EVkLj/?ref=app Note: insert the text with click edit and then type a word and then enter on your keyboard and then repeat doing that min 2 time and try to click li for delete the data.

23rd Feb 2020, 3:44 PM
Hafizd Jubaidir
Hafizd Jubaidir - avatar
4 Antworten
+ 1
do a check before ask for confirmation. check if the element triggering the event is "kosong" or not. if not then continue with the confimation edit: i just see the updated question, doesnt seems like my asnwer is correct edit2: i see the problem. your code keep adding a new listener on every input. thus all of the listener that are registered got triggered. try to limit the add listener to one. or use onclick = instead of addEventListener
23rd Feb 2020, 4:02 PM
Taste
Taste - avatar
0
Taste so how can this no be happening ?
23rd Feb 2020, 4:10 PM
Hafizd Jubaidir
Hafizd Jubaidir - avatar
0
see my updated answer
23rd Feb 2020, 4:12 PM
Taste
Taste - avatar
0
Taste thanks it's solve now
23rd Feb 2020, 5:04 PM
Hafizd Jubaidir
Hafizd Jubaidir - avatar