Sign up (with export icon)

ElementReplacer

Api-class icon class

Utility class allowing to hide existing HTML elements or replace them with given ones in a way that doesn't remove the original elements from the DOM.

Properties

Methods

  • Chevron-right icon

    replace( element, [ newElement ] ) → void

    Hides the element and, if specified, inserts the the given element next to it.

    The effect of this method can be reverted by restore.

    Parameters

    element : HTMLElement

    The element to replace.

    [ newElement ] : HTMLElement

    The replacement element. If not passed, then the element will just be hidden.

    Returns

    void
  • Chevron-right icon

    restore() → void

    Restores what replace did.

    Returns

    void