Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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/

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading