What is the logic of the work of the DOM while adding and removing handlers in my case?

0 like 0 dislike
38 views
Hi!
Prepared sample of codepan.
The problem is the following:
Add an element in the DOM with class user-button at the same time want to hang the handler click on all the items user-button, not hung several handlers after each function call, I removed the handler for the click each item and then add again, but something is not removed as I want.
5ae9bcf565dcd257283774.png

ie every time I click on + the handler is still added to the previous items, do not understand how the DOM works.
Pliz explain!
PS well, or if you know another solution I would be glad to hear :)
by | 38 views

1 Answer

0 like 0 dislike
Nonsense some do. Use delegation. For example, so.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
33,895 users