I am looping through some elements using jQuery’s .each() and I want to delete a node when it meets certain requirements. I’m unsure of the syntax for this, I’ve tried several things:
$(this).remove();
$xml.remove(this);
$xml.removeNode(this);
…etc. Having some trouble finding a working example, could somebody point me in the right direction? I’m assuming it’s simple, I just haven’t been able to find the correct syntax. Got a non-working fiddle below.
Thanks
That’s because the call to
remove()only removes the element from the DOM. It does not remove it from your$siblingsjQuery object.If you call
find()again to rematch the siblings after removing thealexnode, you will get the expected results:You will find an updated fiddle here.