[thelist] changing class style with JS
Hassan Schroeder
hassan at webtuitive.com
Fri Oct 25 18:04:01 CDT 2002
Chris Evans wrote:
> Is there a way to change elements of a CSS class using Javascript?
Say you want to change the color of any rule containing class
"foo" to red --
function changeStyles()
{
var ss = document.styleSheets;
for (i=0;i<ss[0].cssRules.length;i++)
{
if ( ss[0].cssRules[i].selectorText.indexOf(".foo") > -1 )
{
ss[0].deleteRule(i);
ss[0].insertRule(".foo { color: rgb(255,0,0); }", i);
}
}
}
Only tested on Moz (1.1)/Win - YMMV :-)
--
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com
dream. code.
More information about the thelist
mailing list