Color Palette Picker
Using event listeners in a loop
Lesson Objectives
Generate 150 divs (squares) each with their own random color.
<button id="generate">GENERATE</button>
<div id="container">
<div id="color-palette"></div>
<div id="my-palette"></div>
</div>div {
border: 1px solid white;
}
#container {
width: 608px;
}
#color-palette, #my-palette {
display: inline-block;
width: 300px; height: 500px;
overflow: hidden;
}
.square {
display: inline-block;
width: 28px; height: 28px;
cursor: pointer;
}
Last updated