---
name: "up.element.replace"
area: "API"
kind: "JavaScript function"
parent: "up.element module"
visibility: "deprecated"
url: "https://unpoly.com/api/up.element.replace"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.element module](https://unpoly.com/api/up.element.md)</nav>

# up.element.replace(oldElement, newElement)

**This feature has been deprecated**. Use [`Element#replaceWith()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceWith) instead.

Load [`unpoly-migrate.js`](https://unpoly.com/changes/upgrading.md) to polyfill deprecated features.

Replaces the given old element with the given new element.

The old element will be removed from the DOM tree.

---

## Parameters {#parameters}

### oldElement {#oldElement}

(required)

Type: [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)

### newElement {#newElement}

(required)

Type: [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)

