Buzogany Laszlo
Buzogany Laszlo

Reputation: 941

jQuery - Listening element removal live

Is is possible to listen element removals from DOM with a jQuery live event?

I need something like:

$('body').on('remove', '.selector', function() {
  console.log('Element removed.');
});

But it is not working :(

Upvotes: 1

Views: 42

Answers (1)

Tân
Tân

Reputation: 1

Maybe what you're looking for:

$.fn.customRemove = function () {
    $(this).remove();
    console.log('Element removed.');
};

$('.selector').customRemove(); // you will get the log automatically

Upvotes: 4

Related Questions