[thelist] changing class style with JS
Chris Evans
chris at fuseware.com
Mon Oct 28 15:00:01 CST 2002
I modified the script from ppk's site to come up with this script:
<script>
function changeIt(changeClass,newColor)
{
if (!document.styleSheets) return;
var theRules = new Array();
if (document.styleSheets[0].cssRules)
theRules = document.styleSheets[0].cssRules
else if (document.styleSheets[0].rules)
theRules = document.styleSheets[0].rules
else return;
for (i=0;i<theRules.length;i++)
{
if (theRules[i].selectorText != null &&
theRules[i].selectorText.indexOf(changeClass) > -1)
{
theRules[i].style.color = newColor;
}
}
}
</script>
It seems to work in most modern browsers, and when it doesn't work, it
doesn't throw any errors. Since the fucntionality is a "nice, but not
required", it does the trick.
Thanks for all the suggestions!!
--
Chris Evans
chris at fuseware.com
http://www.fuseware.com
More information about the thelist
mailing list