Skip to content Skip to sidebar Skip to footer

Jquery.bind("remove")

Is there a way have an event handler run when a dom element is removed? I have not seen this documented anywhere. It seems it mightt be possible since jQuery is able to remove da

Solution 1:

Binding DOMNodeRemoved will allow for you to detect removal of nodes inside the bound element. Works in Firefox, Iron and Opera... but not IE.

jQuery

$("#detectchanges").bind("DOMNodeRemoved",function(){
  alert('Something inside of detectchanges was terminated.');
});

$("#clickme").click(function(){
  $("#deleteme").remove();
});

HTML

<div id="detectchanges">
  <div id="deleteme">Delete me</div>
</div>

<div id="clickme">Delete</div>

Here's an example.

Post a Comment for "Jquery.bind("remove")"