PDA

View Full Version : How to dynamically change a style?


yandina
08-27-2005, 07:05 AM
I have
<STYLE type="text/css">
.SEQ {font-size:x-large; color:"AQUA"; font-weight:bold; font-style:italic; visibility:hidden}
</STYLE>

There are numerous sections of text in the body using this style (although in different tags)

I want to be able to change the visibility of them all under certain conditions by modifying the style.

Seems simple but I know just enough to get into trouble and not enough to get out. :D

martin_narg
08-27-2005, 08:55 AM
Not too neat, but it works. Changes all SEQ class elements to SEQ2 class, which is visible.

<script type="text/javascript">
function changeSEQ() {
var els = document.getElementsByTagName("body")[0].getElementsByTagName("*");
for(var i=0; els[i]; i++) {
if(els[i].className == "SEQ") {
els[i].className = "SEQ2";
}
}
}
</script>
<style type="text/css">
.SEQ {font-size:x-large; color:"AQUA"; font-weight:bold; font-style:italic; visibility:hidden}
.SEQ2 {font-size:x-large; color:"AQUA"; font-weight:bold; font-style:italic; visibility:visible}
</style>

Hope this helps

m_n