If a DOM Element is removed, are its listeners also removed from memory?

后端 未结 6 1676
北荒
北荒 2020-11-22 06:18

If a DOM Element is removed, are its listeners removed from memory too?

6条回答
  •  悲&欢浪女
    2020-11-22 06:57

    Regarding jQuery, the following common methods will also remove other constructs such as data and event handlers:

    remove()

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

    empty()

    To avoid memory leaks, jQuery removes other constructs such as data and event handlers from the child elements before removing the elements themselves.

    html()

    Additionally, jQuery removes other constructs such as data and event handlers from child elements before replacing those elements with the new content.

提交回复
热议问题