Manipulate the DOM Tree
Elemento has static helpers methods in Elements that help you to manipulate the DOM tree:
Elements.lazyAppend(Element parent, Element child)Appendschildtoparent. Ifparentalready containschild, this method does nothing.Elements.insertAfter(Element newElement, Element after)InsertsnewElementintoafter's parent afterafter.Elements.lazyInsertAfter(Element newElement, Element after)InsertsnewElementintoafter's parent afterafter. Ifafter's parent already containsnewElement, this method does nothing.Elements.insertBefore(Element newElement, Element before)InsertsnewElementintobefore's parent beforebefore.Elements.lazyInsertBefore(Element new Element, Element before)InsertsnewElementintobefore's parent beforebefore. Ifbefore's parent already containsnewElement, this method does nothing.Elements.insertFirst(Element parent, Element newElement)InsertsnewElementas the first element intoparent.Elements.removeChildrenFrom(Element element)Removes all child elements fromelementElements.failSafeRemove(Node parent, Element child)Removeschildfromparent.Elements.failSafeRemoveFromParent(Element element)Removeselementfrom its parent.
All methods are null-safe, check parent/child relationships, and are overloaded to accept an instance of IsElement<Element> instead of Element. See the API documentation of Elements for more details.
Last updated