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

# up.extract(target, html, [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.

Updates a selector on the current page with the same selector from the given HTML string.

<nav aria-label="Contents">

#### Contents

- [Example](#example)
- [Parameters](#parameters)
- [Return value](#return-value)

</nav>

## Example {#example}

Let's say your current HTML looks like this:

```
<div class="one">old one</div>
<div class="two">old two</div>
```

We now replace the second `<div>`, using an HTML string as the source:

```
html = '<div class="one">new one</div>' +
       '<div class="two">new two</div>'

up.extract('.two', html)
```

Unpoly looks for the selector `.two` in the strings and updates its contents in the current page. The current page now looks like this:

```
<div class="one">old one</div>
<div class="two">new two</div>
```

Note how only `.two` has changed. The update for `.one` was discarded, since it didn't match the selector.

---

## Parameters {#parameters}

### target {#target}

(required)

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

### html {#html}

(required)

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 will be fulfilled when the selector was updated.

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

