//*** This code is copyright 2004 by Gavin Kistner, !@phrogz.net //*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt //*** Reuse or modification is free provided you abide by the terms of that license. //*** (Including the first two lines above in your source code mostly satisfies the conditions.) // Find the CSS rule by its selector text, in any styleshet // e.g. FindRule2( 'a.selected' ).style.fontWeight='bold'; function FindRule2(selText){ for (var j=document.styleSheets.length-1;j>=0;j--){ var ss = document.styleSheets[j]; var cache = ss.cssRulesCache = ss.cssRulesCache || {}; //screw case sensitivity; IE and Mozilla don't agree on case for elements themselves selText=selText.toLowerCase(); if (cache[selText]) return cache[selText]; var rules = ss.cssRules || ss.rules; for (var i=0,len=rules.length;i