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

Returns the value of the given attribute on the given element, cast to a number.

If the attribute value cannot be cast to a number, `undefined` is returned.

---

## Parameters {#parameters}

### element {#element}

(required)

The element from which to retrieve the attribute value.

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

### attribute {#attribute}

(required)

The attribute name.

Type: string

---

## Return value {#return-value}

The cast attribute value.

Type: number | undefined

