How to remove all following elements even on higher levels? nextAll() up to root?
Assume I identified a certain element.
Now I want to remove ALL following elements. I can do this with
- $(".foobar"):nextAll().remove();
The problem is, that this removes only elements on the same hierarchy level (=brothers).
Ok, I could go one step upwards:
- $(".foobar"):parent().nextAll().remove();
But maybe there a many (unknown) parents() of parents().
I want to get rid of all the stuff which follows the referred element regardless of the hierarchy level.
How can I achieve this?
Peter