---
name: "up.Preview.prototype.hide"
area: "API"
kind: "Instance method"
parent: "up.Preview class"
url: "https://unpoly.com/api/up.Preview.prototype.hide"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.Preview class](https://unpoly.com/api/up.Preview.md)</nav>

# up.Preview.prototype.hide([element])

Temporarily [hides](https://unpoly.com/api/up.element.hide.md) an element.

The element will be [shown](https://unpoly.com/api/up.element.show.md) when the preview [ends](https://unpoly.com/learn/previews.md#ending).

> #### Tip
>
> To visually remove elements during a preview, prefer hiding over detaching. See [Prefer additive changes](https://unpoly.com/learn/previews.md#prefer-additive-changes).

## Example {#example}

This preview hides an element `#nav` while the request is loading:

```js
up.preview('hide-nav', function(preview) {
  preview.hide('#nav')
})
```

---

## Parameters {#parameters}

### [element=this.fragment] {#element}

(optional)

The element or selector to change.

If omitted, the [targeted fragment](https://unpoly.com/api/up.Preview.prototype.fragment.md) will be changed.

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

