PDA

View Full Version : Changing box background-color


pinkotoad
08-21-2002, 05:16 AM
What I would like to is onmouseover change the background-color of a box. I'm not quite sure on how to do this...

Also, if I wanted to make the entire box a link, would: <a href="#"><div style="cursor:hand;"></div></a> be the best way to do it...or is there something I'm missing?

Thanks

pardicity3
08-21-2002, 06:22 AM
Hmm, when you say box do you mean a table cell?? If so, you can try something like this to change the color on mouseover:

<td onmouseover="this.style.backgroundColor='#FFFFFF';" onmouseout="this.style.backgroundColor='#666666;"></td>

Of course, you would use your own colors that you wanted. and for the link thingy maybe try this:

<td onclick="window.location='http://www.yoursite.com';"></td>

Hope that helps....and also, even if your not talking about table cells, that code will work in most places, though I will warn you that the background Color trick only works in IE4+(I think it's 4 atleast) and NS6+.

Good luck!!!!

pinkotoad
08-21-2002, 07:56 AM
Thanks! Thats actually exactly what I came up with (except I had background-color. doh)... Onmouseover over didnt work quite right (did nothing). then I realized, since that backgroundcolor is also defined in my css file, I can just give onmouseout: "this.style.backgroundcolor=''" and it works beatifully.

It's always the little things that get me :mad:

David