Published in: JavaScript
URL: http://bmky.net/text/note/javascript-css.html
function getStyleValue( selector, property, sheetindex ) { selector = selector.toLowerCase( ) if( sheetindex == undefined ) sheetindex = 0; if( property.indexOf( "-" ) != -1 ) property = property.camelize( ); var rules = document.styleSheets[ sheetindex ].rules //IE || document.styleSheets[ sheetindex ].cssRules; //Mozilla for( var i = rules.length - 1; i >= 0; i-- ) { var rule = rules[i]; if( rule.selectorText.toLowerCase( ) != selector || rule.style[ property ] == "" ) continue; return rule.style[ property ]; } return null; }
You need to login to post a comment.
