PDA

View Full Version : Changing the background color to a TD


sasarivera
05-29-2002, 04:15 PM
Hi,

I have a table very simple.

Section 1 2 3 4 (1 row, 5 cols)

Initially the tds have backgroundcolor white, I just want to change the color through javascript, but is not working.

First I tried with span:

<table>
<tr><td>Section</td>
<td><span id="s1">1</span></td>
<td><span id="s2">2</span></td>
<td><span id="s3">3</span></td>
<td><span id="s4">4</span></td></tr>
</table>
...
My javascript was something like:
s1.style.backgroundcolor = "#5593bf";

The problem was only the number's backgound changed, I need to change the TD's background.

so, I tried assigning the ID to the TD, but nothing happens. Any Ideas???

Thanks in advance for your help.

Jon Hanlon
05-29-2002, 06:35 PM
Use backgroundColor instead of backgroundcolor.
(It's case-sensitive).


<table>
<tr><td>Section</td>
<td id="s1">1</span></td>
<td id="s2">2</td>
<td id="s3">3</td>
<td id="s4">4</span></td>
</tr>
</table>

s1.style.backgroundColor = "#5593bf";
s2.style.backgroundColor = "#5593bf";
s3.style.backgroundColor = "#5593bf";
s4.style.backgroundColor = "#5593bf";