I am expecting the element, id="colorDisp"
to change color when I run one of the functions below, but instead the body
element changes color.
Code below:
function red()
{
document.body.style.backgroundColor = "red";
}
function blue()
{
document.body.style.backgroundColor = "blue";
}
function yellow()
{
document.body.style.backgroundColor = "yellow";
}
function green()
{
document.body.style.backgroundColor = "green";
}
function orange()
{
document.body.style.backgroundColor = "orange";
}
function violet()
{
document.body.style.backgroundColor = "violet";
}
function grey()
{
document.body.style.backgroundColor = "grey";
}
function black()
{
document.body.style.backgroundColor = "black";
}
function cream()
{
document.body.style.backgroundColor = "#ffe6e6";
}
function fushia()
{
document.body.style.backgroundColor = "#ff00bf";
}
function white()
{
document.body.style.backgroundColor = "white";
}
<center>
<table style="padding-top: 200px;font-size:45">
<tr>
<td style="background-color:#ff0040"><a href = "#" onclick = "red()">red</a></td>
<td style="background-color:#00bfff"><a href = "#" onclick = "blue()">blue</a></td>
<td rowspan="5"width="300px" id="colorDisp" style="background-color:black"></td>
</tr>
<tr>
<td style="background-color:#ffff00"><a href = "#" onclick = "yellow()">yellow</a></td>
<td style="background-color:#80ff00"><a href = "#" onclick = "green()">green</a></td>
</tr>
<tr>
<td style="background-color:#ffbf00"><a href = "#" onclick = "orange()">orange</a></td>
<td style="background-color:#8000ff"><a href = "#" onclick = "violet()">violet</a></td>
</tr>
<tr>
<td style="background-color:#808080"><a href = "#" onclick = "grey()">grey</a></td>
<td style="background-color:#000000"><a href = "#" onclick = "black()">black</a></td>
</tr>
<tr>
<td style="background-color:#ffe6e6"><a href = "#" onclick = "cream()">cream</a></td>
<td style="background-color:#ff00bf"><a href = "#" onclick = "fushia()">fushia</a></td>
</tr>
</table>
</center>
Example output for the code above:
[1]http://i.imgur.com/lhqdFoi.jpg
This is sample output for my question
[2]http://i.imgur.com/cZw4iT3.jpg