Coloring layers for easier layout -
12-22-2005
, 10:22 AM
Howdy.
Here's a Javascript function I wrote to automatically add different
background colors to each DIV layer on a page. I find it useful
for fine-tuning layout during development. It's a lot easier than
hard-coding the background colors and then removing them.
Ok, it's trivial. But this should save _someone_ from having to
write it. Enjoy.
-Mark
----------------------------------
function color_layers()
{
// This function adds background colors to all DIV layers
// for easier layout during development.
var colors = new Array("red","blue","green","yellow","orange","brow n",
"gray","purple","teal","fuchsia","lime","maroo n",
"navy","olive","silver");
var c = 0;
var i = 0;
var divs = document.getElementsByTagName("div");
for (i=0;i<divs.length;i++)
{divs[i].style.backgroundColor = colors[c];
c==colors.length-1?c=0:c++;
}
} |