html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE HTML>
<html>
<head>
<script src="colors.js"></script>
</head>
<body>
<p>
This document is a useful tool to
help you find the rgb values you
need for your own documents in
either decimal or hexadecimal form.
It is also a good demonstration of
styling and scripting an html
document.
</p>
<table>
<tbody>
<tr>
<th style="color:red">Red</th>
<th style="color:green">Green</th>
<th style="color:blue">Blue</th>
</tr>
<tr>
<td id="valRed">255</td>
<td id="valGreen">255</td>
<td id="valBlue">255</td>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
body {
background-color: #000;
padding:10px;
color: white;
}
#combo{
color: black;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function changeRed(value){
document.getElementById("valRed").innerHTML=value;
document.getElementById("red").style.backgroundColor=rgb(value,0,0);
changeColor();
}
function changeGreen(value){
document.getElementById("valGreen").innerHTML=value;
document.getElementById("green").style.backgroundColor=rgb(0,value,0);
changeColor();
}
function changeBlue(value){
document.getElementById("valBlue").innerHTML=value;
document.getElementById("blue").style.backgroundColor=rgb(0,0,value);
changeColor();
}
function rgb(r,g,b){
return "rgb("+r+","+g+","+b+")";
}
function changeColor(){
var red=Number(document.getElementById("slideRed").value);
var green=Number(document.getElementById("slideGreen").value);
var blue=Number(document.getElementById("slideBlue").value);
document.getElementById("combo").style.backgroundColor=rgb(red,green,blue);
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run