getPropertyValue() is a method in the CSSStyleDeclaration interface (an object that exposes style information to be queried using JavaScript). It returns the value of the property that is passed in through its' parameter.
Description
getPropertyValue() is method in the CSSStyleDeclaration interface (an object that exposes style information to be queried using JavaScript). It returns the value of the property that is passed in through its' parameter.
Syntax
Given a stylesheet of:
div {
font-weight: bold;
color: red;
}
span{
color: blue;
font-weight: normal;
}
to get the font-weight property of the first style would be:
var value = document.styleSheets[0].cssRules[0].style.getPropertyValue('font-weight');
which returns "bold".
to get the font-weight property of the second style would be:
var value = document.styleSheets[0].cssRules[1].style.getPropertyValue('font-weight');
Notice that if the property has a dash then it must be specified as it is, instead of fontWeight, as is normally seen in JavaScript when using methods like .getElementById()
References