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) Appends child to parent. If parent already contains child, this method does nothing.

  • Elements.insertAfter(Element newElement, Element after) Inserts newElement into after's parent after after.

  • Elements.lazyInsertAfter(Element newElement, Element after) Inserts newElement into after's parent after after. If after's parent already contains newElement, this method does nothing.

  • Elements.insertBefore(Element newElement, Element before) Inserts newElement into before's parent before before.

  • Elements.lazyInsertBefore(Element new Element, Element before) Inserts newElement into before's parent before before. If before's parent already contains newElement, this method does nothing.

  • Elements.insertFirst(Element parent, Element newElement) Inserts newElement as the first element into parent.

  • Elements.removeChildrenFrom(Element element) Removes all child elements from element

  • Elements.failSafeRemove(Node parent, Element child) Removes child from parent.

  • Elements.failSafeRemoveFromParent(Element element) Removes element from 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