Should I remove the handler for an event when the DOM element is deleted?
1 answer
If you later create an element with the same ID, then yes, you should remove the handler. If, when deleting an object, you know that afterwards you will not create this object with the same ID, then you can not add a headache to yourself and not delete events to the element.
- oneItem id does not matter. Each element in the tree has its own unique identifier. The handler hangs on a specific element, when it is removed from the tree, the handler is also reset, the proof is Rolandius
|