Forum Moderators: not2easy

Message Too Old, No Replies

tablecell onmouseover/out

what does the css code look like?

         

Srs_Hcm

1:29 pm on Jul 28, 2004 (gmt 0)

10+ Year Member



Hi folks,

I was wondering how i could add onmouseover and onmouseout to the css of a table cell.

At the moment i use this code for each cell:
<td class="cell" onmouseover="style.backgroundColor='#FFFFFF';" onmouseout="style.backgroundColor='#EFEFF7'"></td>

I can't figure out how to use css to get same effect.
anyone?

thx in advance!

encyclo

1:33 pm on Jul 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, Srs_Hcm.

You are using CSS to a certain extent, but combined with Javascript.

In theory, you can use

td:hover
to apply the desired effect, like this:

td {background-color:#efeff7;} 
td:hover {background-color:#fff;}

In reality, Internet Explorer does not support

:hover
on anything other than link anchors, so you are forced to use the Javascript solution you have already.

Srs_Hcm

2:36 pm on Jul 28, 2004 (gmt 0)

10+ Year Member



thx for the quick reply

i've searched and searched for a way how to do this...but now it makes sense why i never found it :)

Cheers!

SuzyUK

6:20 pm on Jul 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If using javasript solution anyway, you can also be use the whatever:hover [xs4all.nl] behaviour file instead.

This allows you to use the CSS :hover attribute (as intended) in IE. yes it still requires js enabled, but the HTML code remains nice and neat (no typing js calls in there) the code all goes into the CSS file which links to the behaviour file..

Plus the added advantage that when/if future versions of IE ever start supporting it you can lessen the dependency on the behaviour file call.

Suzy