Can you please take a look at this Demo and let me know how to fix the issue on this code?
<div id="out"></div>
<script>
$(document).ready(function () {
var colors = new Array("#FFF", "#CCC", "#7FFF00");
for (var i = 0; i < colors.length; i++) {
$("#out").append('<div class="box"></div>');
$(".box").css("background-color",colors[0]);
}
});
</script>
what I am trying to do is generating div elements based on an array length and set the background of them from the colors array
Thanks