Is it necessary to disable events from elements deleted from the document

I am using jQuery and I would like to know if the remove () method clears its contents of event handlers. For instance:

function someFunction() { var element = $('<div></div>'); element.click(function() { alert('bar'); }); $('body').append(element); element.remove(); } 

At this point, is the memory still listening to events? If so, is there a way to clear the event handler element before deleting it from the DOM?

+4
source share
1 answer

According to jquery docs :

In addition to the elements themselves, all related events and jQuery data associated with the elements are deleted.

+7
source

Source: https://habr.com/ru/post/1369077/


All Articles