Edit this page

up.element up.element.styleNumber(element, prop)
JavaScript function

Receives a computed CSS property value for the given element, casted as a number.

The value is casted by removing the property's unit (which is usually px for computed properties). The result is then parsed as a floating point number.

Returns undefined if the property value is missing, or if it cannot be parsed as a number.

Examples

When requesting a single CSS property, its value will be returned as a string:

value = up.element.style(element, 'font-size')
// value is '16px'

value = up.element.styleNumber(element, 'font-size')
// value is 16

Parameters

element Element
prop string

A single property name in kebab-case or camelCase.

Return value

numberorundefined