I suggest this function:
function css( element, property ) {
return window.getComputedStyle( element, null ).getPropertyValue( property );
}
Usage:
css( object, 'font-size' ) // returns '16px' for instance
Note: getComputedStyle
doesn’t work in IE8.
Live demo: http://jsfiddle.net/4mxzE/
console.log(
getComputedStyle(document.getElementById('test'), null)
.getPropertyValue('font')
)
#test {
font-family: fantasy, cursive;
}
<div id="test">Lorem ipsum dolor sit font-face</div>