Home > Mobile >  Post processing elements after a remove() using a function is not working
Post processing elements after a remove() using a function is not working

Time:04-18

I am removing a cloned element using remove()

I have some post removal processing to do on any remaining clones and I need to ensure that the element has left the dom before I do this. I have attempted the following:

$('#something').remove(function() {
    ... stuff to do after the remove is complete...
})

However the '... stuff to do after the remove is complete...' never fires. Is this the best way to ensure an element is removed before post processing and if so what am I doing wrong?

CodePudding user response:

According to the doc, the remove function don't take a callback as parameter.

This is a synchronous function, so, you only have to execute your code on a new line.

$('.selector').remove();
console.log( $('.selector').length );

https://api.jquery.com/remove/

  • Related