Question

(b) Write a JavaScript function that displays the 216 web safe colours with their hex values in a 36 × 6 table. In an RGB col

0 0
Add a comment Improve this question Transcribed image text
Answer #1

<html>
<head><title>Web Safe Colours</title>
<style type="text/css" media="all">
.webColors {
display: inline-block;
width: 65px;
height: 25px;
}
</style>
<body onload="palette()">
<div id="colors"></div>
</body></head>
</html>

function palette(){
var components = ['00', '33', '66', '99', 'CC', 'FF'];
for(var red = 0; red < components.length; red++){
for(var green = 0; green < components.length; green++){
for(var blue = 0; blue < components.length; blue++){
   var colorDiv = document.createElement('div');
colorDiv.className = 'webColors';
colorDiv.innerHTML=   '#' + components[red] + components[green] + components[blue];
colorDiv.style.backgroundColor =
   '#' + components[red] + components[green] + components[blue];
   colors.appendChild(colorDiv);
if(blue=== 5){
       var br = document.createElement('br');
       colors.appendChild(br);
   }
}
}
}

Output:-000099-000CC #0000FF #003366 #003399 #0033CC #0033FF 06600 #006633 #006666 #006699 #0066CC #0066FF 009900 #009933 #009966 #0
}

Add a comment
Know the answer?
Add Answer to:
(b) Write a JavaScript function that displays the 216 web safe colours with their hex values in a 36 × 6 table. In an R...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT