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. Returns NaN if the value cannot parsed as a number.

Examples

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

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

Parameters

element Element
prop string

A single property name in kebab-case.

Return value

numberorundefinedorNaN