I want the for a div a different color and width specified by means of two arrays and in a for
loop but I can't find how to get this done. So I have 5-divs that all should have a different color and a separate width.
Does anyone here have any experience with that and can help me? Thanks.
<html>
<head>
<title>Hoi</title>
<script type="text/javascript">
var color = Array("#F00","#FF0","#0F0","#0FF","#00F");
var width = Array("20", "40", "60", "80", "100");
{
for (i=0; i<5; i++)
{
document.getElementById('div'+i).style.backgroundColor = color[i];
document.getElementById('div'+i).style.width = width[i];
}
}
</script>
</head>
<body>
<div id="div1">div1</div>
<div id="div2">div2</div>
<div id="div3">div3</div>
<div id="div4">div4</div>
<div id="div5">div5</div>
</body>
</html>