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


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
49 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 | 49 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,187 answers
0 comments
40,796 users