Edit this page

up.element up.element.attr(element, attribute)
JavaScript function

Returns the given attribute value for the given element.

If the element does not have the given attribute, it returns undefined. This is a difference to the native Element#getAttribute(), which mostly returns null in that case.

If the element has the attribute but without value (e.g. <input readonly>), it returns an empty string.


Parameters

element
required

The element from which to read an attribute.

attribute
required

The name of the attribute to read.

string

Return value

The attribute value.

Returns undefined if the attribute is not set on the given element.

stringundefined