View Full Version : change bg cell color

12-26-2005, 08:38 PM
I need a very simple script that will change the table's cell background color and add a 1px border with EAEAEA color.

How do I go about implementing this?

I got:

<td bgcolor="#FFFFFF" onMouseover="this.style.backgroundColor='F8F8F8';" onMouseout="this.style.backgroundColor='FFFFFF';" align="center" width="152">

I am not sure how to add the border portion for "onmouse"

Thank you in advance

12-26-2005, 09:27 PM
Here's one way of dealing with that:

<td style="background-color:#ffffff;border:1px solid #ffffff;text-align:center;width:152px;" onmouseover="this.style.backgroundColor='#d0d0d0';this.style.borderColor='#000000';" onmouseout="this.style.backgroundColor='#ffffff';this.style.borderColor='#ffffff';">hi</td>

12-26-2005, 09:32 PM
Thanks. Didn't work

<td style="background-color:#ffffff;border:1px solid #ffffff; onMouseover="this.style.backgroundColor='F8F8F8';this.style.borderColor='EAEAEA';" onMouseout="this.style.backgroundColor='FFFFFF';" align="center">

What did I do wrong? Basically, nothing happens now (even bg color) when hovered over the cell

12-26-2005, 11:17 PM
For one thing, you did a poor job of cut and paste. I used to hate that in elementary school, so don't feel bad. Anyways, try copying my code and pasting it into your page. You can change the color values after that. One important consideration is that although not all browsers require it all the time, hex color codes should always be preceded with the # symbol. Most browsers do require it at least some of the time, some require it all the of time. One other thing, using onMouseover (it should be onmouseover) is a bad habit, it can get you into trouble with certain strict page parsings. On the other hand, when not hyphenated and used as javascript, things like backgroundColor require the 'Camel' style notation.