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)
Appendschild
toparent
. Ifparent
already containschild
, this method does nothing.Elements.insertAfter(Element newElement, Element after)
InsertsnewElement
intoafter
's parent afterafter
.Elements.lazyInsertAfter(Element newElement, Element after)
InsertsnewElement
intoafter
's parent afterafter
. Ifafter
's parent already containsnewElement
, this method does nothing.Elements.insertBefore(Element newElement, Element before)
InsertsnewElement
intobefore
's parent beforebefore
.Elements.lazyInsertBefore(Element new Element, Element before)
InsertsnewElement
intobefore
's parent beforebefore
. Ifbefore
's parent already containsnewElement
, this method does nothing.Elements.insertFirst(Element parent, Element newElement)
InsertsnewElement
as the first element intoparent
.Elements.removeChildrenFrom(Element element)
Removes all child elements fromelement
Elements.failSafeRemove(Node parent, Element child)
Removeschild
fromparent
.Elements.failSafeRemoveFromParent(Element element)
Removeselement
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