The style property gives access to these inline styles, it will always overrule all other styles.
The general rule is that all dashes are removed from the CSS property names, and that the character after a dash becomes uppercase.
margin-left becomes marginLeft, text-decoration becomes textDecoration, and border-left-style becomes borderLeftStyle.
// Microsoft and W3C have created ways of accessing non-inline styles.
function getRealStyle(elt,styleName)
{
var realStyle = null;
if (elt.currentStyle)
realStyle = elt.currentStyle[styleName];
else if (window.getComputedStyle)
realStyle = window.getComputedStyle(elt,null)[styleName];
return realStyle;
}
文章標籤
全站熱搜