View Single Post
Old 02-06-2003, 10:16 PM   PM User | #1
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
changing element styles in real time

I'm using sliders to change text colour dynamically; at the moment, I'm doing it by iterating through the getElementsByTagName collection; like

Code:
paraAry = document.getElementsByTagName("p");
paraLen=paraAry.length;
for(j=0;j<paraLen;j++){
	paraAry[j].style.color = "rgb("+bodyColor[0]+","+bodyColor[1]+","+bodyColor[2]+")";
	paraAry[j].style.borderColor = "rgb("+textColor[0]+","+textColor[1]+","+textColor[2]+")";
	paraAry[j].style.backgroundColor = "rgb("+textColor[0]+","+textColor[1]+","+textColor[2]+")";
	}

But blatantly it's well inefficient; is there a better way to achieve this - like just a single property I can change to make all elements of a given name change.

Last edited by brothercake; 02-06-2003 at 11:08 PM..
brothercake is offline   Reply With Quote