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

# up.replace(target, url, [options])

**This feature has been deprecated**. Use [`up.render()`](https://unpoly.com/api/up.render.md) or [`up.navigate()`](https://unpoly.com/api/up.navigate.md) instead.

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

Replaces elements on the current page with corresponding elements from a new page fetched from the server.

---

## Parameters {#parameters}

### target {#target}

(required)

The CSS selector to update. You can also pass a DOM element or jQuery element here, in which case a selector will be inferred from the element's class and ID.

Type: string | [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) | [jQuery](https://learn.jquery.com/using-jquery-core/jquery-object/)

### url {#url}

(required)

The URL to fetch from the server.

Type: string

### [options] {#options}

(optional)

See `options` for [`up.render()`](https://unpoly.com/api/up.render.md).

Type: [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects)

---

## Return value {#return-value}

A promise that fulfills when the page has been updated.

Type: [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises)

