---
name: "up.element.setAttrs"
area: "API"
kind: "JavaScript function"
parent: "up.element module"
url: "https://unpoly.com/api/up.element.setAttrs"
---
<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.setAttrs(element, attributes)

Sets properties from the given object as attributes on the given element.

## Example {#example}

```js
up.element.setAttrs(element, { title: 'Tooltip', tabindex: 1 })

element.getAttribute('title') // result: "Tooltip"
element.getAttribute('tabindex') // result: "1"
```

---

## Parameters {#parameters}

### element {#element}

(required)

The element on which to set attributes.

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

### attributes {#attributes}

(required)

An object of attribute names and values to set.

To set an empty attribute, pass an empty string value.

To remove an attribute, use a value of `null` or `undefined`.

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

